Tôi viết một số bản ghi vào nhật ký sự kiện sử dụng thư viện doanh nghiệp MicrosoftThiết lập một 'category' trong khai thác gỗ thư viện doanh nghiệp .net (để ghi sự kiện)
nó viết log đi tốt nhưng doesnt dường như thiết lập các loại trong bản ghi sự kiện. Danh mục xuất hiện không sao trong nội dung thư của nhật ký (nếu tôi chọn đặt nội dung đó) nhưng trình xem sự kiện sự kiện không chọn danh mục.
Tôi đang thiếu gì?
C# nguồn
LogEntry log = new LogEntry();
log.Message = "Test";
log.Categories.Add("Event");
Logger.Write(log);
web cấu hình
<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 ** ");'? –
bạn có muốn nói các sự kiện đã đăng nhập trong danh mục của riêng bạn trong trình xem sự kiện không? Hoặc khi bạn xem trong trình xem sự kiện, bạn không thể thấy danh mục trong chi tiết? – curtisk