0
votes

I am upgrading log4j 1 to log4j 2. I have a custom appender created in log4j1 and in append(LoggingEvent event) method I retrieve error stack trace using event.getThrowableStrRep() and append '\t' for each line.

I don't see getThrowableStrRep in log4j2. Could you please help me out how we can do this in log4j2?

1

1 Answers

0
votes

If you would like to custom your own throwable message, you need create your own plugin, which should extend org.apache.logging.log4j.core.pattern.LogEventPatternConverter and override the format method.

After you create your own plugin, refer to http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout for using it.