Sep 22, 2016
Nov 14, 2016
CMS Core
Closed, Fixed and tested
EPiServer.Logging.Log4Net should not append an exception to the message passed to it, since log4net is responsible for this. Especially since you can apply exception tokens to the logging pattern, and thereby specify to log4net exactly where in the logstatement you want the exception. (Right now, Episerver just appends it to the message, even if the formatstring in log4net says it should be in another place).
Example:
Message: "some error has occurred"
Exception stacktrace:
"exception: some exception message
at <some type> in <some file> line:22"
*After EPiServer.Logging.Log4Net: *
Message:
"some error has occurred
exception: some exception message
at <some type> in <some file> line: 22"
Exception stacktrace:
"exception: some exception message
at <some type> in <some file> line:22"
Log4net writes to log:
"some error has occurred
exception: some exception message
at <some type> in <some file> line: 22
exception: some exception message
at <some type> in <some file> line: 22"
Especially problematic if your pattern string is something like:
"%date [%thread] %level %message – %property
{log4net:host}:: %exception"
Then, the fact that Episerver forcefully appends the exception to the message breaks this pattern completely. As this affects everyones logging if changed, we added a configuration option that changes the logging formatter to not append the exception message.
Just add an app setting with key 'episerver:LoggerAppendExceptionMessage' and value 'false'. Configuration needs to be in place when the site starts.