我使用的是微軟的企業庫設置在.NET企業庫記錄一個「類型」(到事件日誌)
其寫入日誌遠細寫一些日誌,事件日誌,但似乎沒有設置類別在事件日誌中。該類別在日誌的消息正文中顯示正常(如果我選擇設置該日誌),但事件查看器不會挑選該類別。
我在想什麼?
C#源
LogEntry log = new LogEntry();
log.Message = "Test";
log.Categories.Add("Event");
Logger.Write(log);
web配置
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add source="TestLogSource" formatter="Text Formatter" log="TestLog"
machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Severity: {severity}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="Events">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
<add switchValue="All" name="General">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
'log.Categories.Add(「Event ** s **」);'? – 2009-11-17 15:47:20
你的意思是你想在事件查看器中將你的記錄事件放在你自己的類別下嗎?或者一旦您在事件查看器中查看它,您無法看到詳細信息中的類別? – curtisk 2009-11-17 16:00:02