Reputation: 3265
I would like to log messages in a jSon format from within Java. I would like the convenience of professional logging like log4j for hierarchical loggers and method names, but I would also like to output other key-value names in the json object.
I am looking for output simillar to this:
{ 'time':'123' , level:'debug', action: 'open',filename:'bla.txt'}
{ 'time':'432' , level:'info', action: 'calculate',result:'353'}
If I use log4j and reformat I cannot get the automatic values (timestamp for example) in the same object as the logged values.
Is there a logging framework or plugin to solve this?
Upvotes: 2
Views: 2902
Reputation: 212
Have a look at elf4j-engine.
JSON and async logging out of the box. JSON pattern is configurable, either minified one-line (default) or pretty print.
Disclaimer: I am the developer of elf4j-provider/elf4j-engine
Upvotes: 1
Reputation: 4183
I started using this project Works great
https://github.com/michaeltandy/log4j-json
Upvotes: 3