Skip to content

NLogExceptionlessLog Missing Exception object #298

@snakefoot

Description

@snakefoot

This should be changed:

public void Error(string message, string source = null, Exception exception = null) {
if (LogLevel.Error < MinimumLogLevel)
return;
_logger.ForErrorEvent().Message(message).LoggerName(source).Log();

To this:

_logger.ForErrorEvent().Message(message).LoggerName(source).Exception(exception).Log(); 

Notice it is a little special that you modify the LoggerName, since this is usually derived from _logger. Can see that log4net does the following:

NLog.LogManager.GetLogger(source ?? GetType().ToString()).ForErrorEvent().Message(message).Exception(exception).Log(typeof(NLogExceptionlessLog)); 

Any reason why not doing the same for NLog ?

P.S the reason for using .Log(typeof(NLogExceptionlessLog)) is to make NLog Callsite work correctly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions