How to format stacktrace in log4j2?
问题 By default log4j2 prints stacktrace on multiple lines, separated by newline characters. Something like: java.lang.NullPointerException: error enovountered at ... at ... at ... I want my stacktrace on a single line, something like, essentially using | as a delimiter rather than \n java.lang.NullPointerException: error enovountered at ... | at ... | at ... How will I accomplish something like this in log4j2? 回答1: As the PatternLayout documentation specifies, the %throwable family of conversion