[ACCEPTED]-NLog logging LogEventInfo and Exception data with one call-nlog

Accepted answer
Score: 13

You just need to set the Exception property to your 1 exception on the LogEventInfo object:

Exception ex = Server.GetLastError();
Logger logger = LogManager.GetCurrentClassLogger();
LogEventInfo eventInfo = new LogEventInfo(LogLevel.Trace,  
    "Hello from RunJob", logger.Name);
eventInfo.Properties["CustomerID"] = "someCustID";
eventInfo.Properties["TargetSite"] "someTargetSite";

eventInfo.Exception = ex; //set the exception for the eventInfo

logger.Log(eventInfo);

More Related questions