0

I noticed from "https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout" that throwables (like exceptions) can be formatted (using '%throwable' : '%throwable{100}/'%throwable{short}' etc...).

Suppose I have the following in Java : logger.error("Exception in getUser :", ex);

I have also the following Pattern Regex in the log4j xml settings file: "[%d] %logger{36} [%l] %-5level %m %n"

I noticed that the exceptions logged at THE END of the log line even if the '%throwable' does not appear in the Pattern.

My question is : what is the default '%throwable' regex format ? where it is configured ? Is it suppose to be like that ? logged at the end of the error log line ?

Thanks,

idanH
  • 1

1 Answers1

0

As far as I can see for "@m @n" if you don't specify what to do with @throwble, it will inject default @throwable at the end of message (so exception message + stack trace).

You can customize that just by adding "@m @throwable{X} @n", where X is something you can choose from here under the section ex|exception|throwable. For example "@m @throwable{none} @n" will suppress error message.

radekkl
  • 21
  • 4