当我使用 NLog 的默认布局时,它只打印异常的名称。我被告知 log4jxmlevent 布局没有打印任何关于异常的信息。什么布局对我有帮助?
示例代码:
try
{
throw new SystemException();
}
catch (Exception ex)
{
logger.Error("oi", ex);
}
默认布局输出:
2011-01-14 09:14:48.0343|ERROR|ConsoleApplication.Program|oi
log4jxmlevent 输出:
<log4j:event logger="ConsoleApplication.Program"
level="ERROR"
timestamp="1295003776872"
thread="9">
<log4j:message>oi</log4j:message>
<log4j:NDC />
<log4j:locationInfo class="ConsoleApplication.Program"
method="Void Main(System.String[])"
file="C:\Users\User\Documents\Visual Studio 2010\Projects\ConsoleApplication\ConsoleApplication\Program.cs"
line="21" />
<nlog:eventSequenceNumber>3</nlog:eventSequenceNumber>
<nlog:locationInfo assembly="ConsoleApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<log4j:properties>
<log4j:data name="log4japp"
value="true" />
<log4j:data name="log4jmachinename"
value="MACHINE" />
</log4j:properties>