當我使用帶NLog的默認佈局時,它僅打印異常的名稱。 我已經被告知log4jxmlevent佈局不會打印任何關於異常的內容。 什麼佈局會幫助我?如何在使用NLog記錄異常時獲取堆棧跟蹤?
示例代碼:
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>
這是除了現有的佈局? – Shane 2011-10-07 21:00:32
@Shane當然,除非你只需要堆棧跟蹤 – 2012-09-10 14:11:40