You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem description
Passing an exception to the logger does not log the exception in all cases and the message is not always formatted.
Example
Logger.Info("formatted exception {0}.", new Exception("exception message").Message);
Logger.Info("exception {0}.", new Exception("exception message"));
Logger.Info("param and exception {0}.", "some other param", new Exception("exception message"));
Output:
12|2019-10-16 11:41:01.475|INFO|1|Test|formatted exception exception message.
13|2019-10-16 11:41:01.475|INFO|1|Test|exception {0}.>>>System.Exception: exception message<<<
14|2019-10-16 11:41:01.475|INFO|1|Test|param and exception some other param.
works as expected
works but fails to format
fails to log the exception
Conclusion:
Only the methods with signature (string message, params object[] ps); apply formatting
Only the methods with signature (string message, Exception ex = null); log the stack trace
Expected behaviour:
NLog 4 moved the exception parameter in front of the message format string to avoid the confusion. Log4net has extra methods for logging formatted messages with an exception.
MetroLog Logger's interface has a signature close to log4j and slf4j and should behave like it:
The Logger should not make assumptions on wheter an exception is an formatting parameter or whether it has to be logged as an exception.
Both variants should check whether the last argument is an exception and pass it on as exception to the targets.
The text was updated successfully, but these errors were encountered:
Problem description
Passing an exception to the logger does not log the exception in all cases and the message is not always formatted.
Example
Output:
Conclusion:
Only the methods with signature
(string message, params object[] ps);
apply formattingOnly the methods with signature
(string message, Exception ex = null);
log the stack traceExpected behaviour:
NLog 4 moved the exception parameter in front of the message format string to avoid the confusion. Log4net has extra methods for logging formatted messages with an exception.
MetroLog Logger's interface has a signature close to log4j and slf4j and should behave like it:
The text was updated successfully, but these errors were encountered: