Internal log4j logging like below will just log the message but will not report the specified exception:
This is caused by a bug in ParameterizedNoReferenceMessageFactory (the factory used by StatusLogger):
This factory was introduced to resolve memory leaks that appeared in web containers because StatusLogger keeps a ring buffer of previously logged messages and ParameterizedMessage keeps a reference to its parameter objects (
AbstractLogger depends on the Message to get the Throwable when logging a message with parameters, so SimpleMessage is not good enough. I'm thinking to introduce a new class StatusMessage (perhaps as an inner class of ParameterizedNoReferenceMessageFactory in order to keep the API surface small). StatusMessage would have the formatted string and the Throwable (which may be null). That should solve this issue.
If the Throwable is a custom Log4j class like AppenderLoggingException then keeping a reference to it may re-introduce memory leaks again though, but I guess that is a fight for another day...