Let's say I want to log an object Mycustomer using Nlog.
I want to have something like this:
logger.Trace(mycustomer)
Now in the configuration how can I specify which property I want to print? something like:
<target name="output" xsi:type开发者_开发知识库="Debugger" layout="${Name}" />
i got it
instead of logger.log(customer);
i use this to add properties of customer:
NLog.LogEventInfo info = new LogEventInfo(LogLevel.Info,"Name",cus.Name);
info.Properties.Add("Name",cus.Name);
log.Log(info);
and in config i use this to print it:
<target name="output" xsi:type="Debugger" layout="${event-context:item=Name}" />
精彩评论