[ACCEPTED]-NLog logging LogEventInfo and Exception data with one call-nlog
Accepted answer
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);
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.