【发布时间】:2012-05-26 01:04:36
【问题描述】:
是否可以通过代码更改source 名称?我的解决方案有几个模块,我想在查看日志时将它们分开。
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="EventLog" name="eventlog" layout="${message}" log="Application" source="MyAwesomeSolution"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="eventLog" />
</rules>
</nlog>
另外,如何将对象记录为 xml?例如如果我这样做 - logger.Info("Results - {0}", person); 我想在我的事件日志中以 XML 形式查看 person 对象。有可能吗?
【问题讨论】: