[Mono-list] Tracing disregards SourceSwitch and EventTypeFilter
Dave Curylo
curylod at asme.org
Thu Nov 1 19:29:24 UTC 2012
My application outputs tracing using the TraceSource API, writing trace
statements at various levels with TraceEventType.Verbose, Information,
Warning, Error, etc. While the verbose logging is useful during
troubleshooting, most of the time I would like to keep it turned off, so I
use a System.Diagnostics.SourceSwitch to turn down the logging on my
TraceSource entries in my app.config. On Windows, the configured
SourceSwitch is honored, so if set to "Information", then only trace
statements of Information and greater severity appear. However, on Mono
2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2), the SourceSwitch doesn't seem to
have any effect, and neither does an EventTypeFilter. As a result, the
logs are always filled with overly verbose log entries. Is there some way
to configure SourceSwitch and EventTypeFilter so they work under Mono or
are these unsupported?
Here is an example, which doesn't output anything under Windows / .NET (as
expected) since the EventTypeFilter is set to Information and the
SourceSwitch is set to Error. However, on Linux / Mono, the Verbose level
output is displayed.
C# Source:
class Program {
static void Main(string[] args) {
TraceSource trace = new TraceSource("Testing");
trace.TraceEvent (TraceEventType.Verbose, 0, "Testing verbose
event.");
}
}
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<sources>
<source name="Testing" switchName="sourceSwitch"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener"
traceOutputOptions="DateTime,ThreadId">
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Information" />
</add>
</listeners>
</source>
</sources>
<switches>
<add name="sourceSwitch" value="Error" />
</switches>
</system.diagnostics>
</configuration>
Program output:
Testing Verbose: 0 : Testing verbose event.
ThreadId=
DateTime=2012-11-01T15:25:42.9727200-04:00
Thanks for you help.
-Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20121101/9bcb5e0a/attachment.html>
More information about the Mono-list
mailing list