savoirtech / slf4j-json-logger

Apache License 2.0
59 stars 23 forks source link

Matching field names with other log frameworks. #7

Open javadevmtl opened 7 years ago

javadevmtl commented 7 years ago

Hi I'm using slf4j bridged to log4j.

compile 'org.apache.logging.log4j:log4j-core:2.8.2'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.2'
compile 'com.savoirtech.logging:slf4j-json-logger:2.0.2'

When using JsonLayout of Log4j the field name are not the same.

For instance Log4j uses timeMillis and it is the epoch time in milliseconds. While slf4j-json-logger uses at timestamp.

Or thread in log4j vs thread_name in slf4j-json-logger.

What's your take on this? :)

artnaseef commented 7 years ago

Is there a standard out there? I hesitate to simply change the hard-coded constants here due to lack of backward compatibility that would create, but perhaps we can use a configuration file located on the classpath (in a similar manner to log4j.xml) to allow these names to be configured.

Note that it's really straight-forward to add configuration to each logger, but I anticipate that ensuring the configuration is properly set when every logger is instantiated would be challenging.

Thoughts?

javadevmtl commented 7 years ago

It doesn't seem like it. Config would be the only way. I guess or maybe custom layout?

artnaseef commented 7 years ago

I'm going to look at adding a config file for this. I'm also contemplating adding support to override the JSON to output "plain text" via a config file setting - to support use of this library both for json-logging and non-json-logging applications.

zsiegel commented 7 years ago

I would like to give a +1 for allowing a mapping config for the default fields. I am using this with StackDriver logging in kubernetes and I need to map the "level" field to "severity" and a few others. Let me know if I can help get this going in a PR

artnaseef commented 7 years ago

Please see the following issue: https://github.com/savoirtech/slf4j-json-logger/issues/10