[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 (Debian, 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

<?xml version="1.0" encoding="utf-8"?>
<source name="Testing" switchName="sourceSwitch"
<add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener"
 <filter type="System.Diagnostics.EventTypeFilter"
initializeData="Information" />
<add name="sourceSwitch" value="Error" />

Program output:
Testing Verbose: 0 : Testing verbose event.

Thanks for you help.
-------------- 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