Logs in Json format

170 views
Skip to first unread message

Support

unread,
May 5, 2021, 2:39:31 PM5/5/21
to jPOS Users
Hi there, is there any way to get the logs to be printed in json format? Thanks in advance!

Arsalan Khan

unread,
Jun 24, 2021, 9:53:59 AM6/24/21
to jPOS Users
Hi,

I don't think jPOS have logging support in JSON format out of the box but I was recently doing something similar to use jPOS Logger system to write CSV data format to a file. I was able to achieve by creating 2 new classes, let say MyLogListener and MyLogEvent.

public class MyLogEvent extends LogEvent {
    @Override
    public void dump(PrintStream p, String indent) {
        // do whatever you want with the payload
    }
}

Override the dump method in MyLogEvent class and in order to remove opening and closing <logger> tags you may override openLogFile and closeLogFile in your LogListener.
Reply all
Reply to author
Forward
0 new messages