Debug and Trace output are somewhat platform specific.  By default on
Windows, messages are generated with the OutputDebugString Win32 API, so
the messages are visible (a) inside a debugger, and (b) with the
SysInternals.com DebugView utility program.  By default on Unix,
messages are sent to /dev/null (i.e. ignored).

For more control, set the MONO_TRACE environment variable.  The syntax
of possible values is:

        MONO_TRACE := <builtin-location> | <file-name>

        <builtin-location> :=
                ( "Console.Out" | "Console.Error" ) [ ':' <prefix> ]?

        <prefix> := any string of characters

        <file-name> := any valid file name

At least, that's my fast effort for the accepted BNF-like grammar.

For example, to send all messages to standard output (/dev/stdout):

        export MONO_TRACE=Console.Out

For standard error (/dev/stderr):

        export MONO_TRACE=Console.Error

If you want to more easily distinguish between your normal program
output and the messages generated via the Debug and Trace classes, use a
"prefix".  The prefix is printed out before the actual message, and is
separated from the location by a ':':

        export MONO_TRACE="Console.Out:++++ "

Alternatively, you can send all messages to a filename:

        export MONO_TRACE=/tmp/my-file-name.txt

Finally, you can use the program's .config file to specify a file to
write messages to:

        <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
                <system.diagnostics>
                        <assert assertuienabled="false" 
                                logfilename="MY-FILE-NAME.txt"/>
                </system.diagnostics>
        </configuration>

Set (XPath) /configuration/system.diagnostics/assert/@logfilename to the
filename to send messages to.  This is used IN ADDITION TO the filename
specified in MONO_TRACE, if present.

The above is the extent of the DefaultTraceListener support.  You can
always add your own trace listener to send messages to alternate
sources, using a (XPath)
/configuration/system.diagnostics/trace/listeners/add element:

        <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
          <system.diagnostics>
            <trace>
              <listeners>
                <!-- beware line wrap in @type value -->
                <add name="some-unique-name"
                  type="System.Diagnostics.TextWriterTraceListener, System,
Version=1.0.03300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                  initializeData="MY-FILE-NAME.txt"
                />
              </listeners>
            </trace>
          </system.diagnostics>
        </configuration>

(XPath)
/configuration/system.diagnostics/trace/listeners/add/@initializeData
contains the value to pass to the constructor of the type specified in
@type, which is a filename for TextWriterTraceListener.

@type should be on one line; it's so long because .NET requires all that
information to find & load the correct type.  Mono doesn't currently
require all that, so "System.Diagnostics.TextWriterTraceListener,
System" would suffice for @type on Mono.

This mechanism can also be used to add arbitrary TraceListeners of your
own creation, if you wish.  The syntax is the same, just use the
appropriate @type value.

 - Jon

On Thu, 2004-01-01 at 17:27, GUSTAVO GARCIA BERNARDO wrote:
> Hello,
> 
>     How can i enable the System.Diagnostics.Debug class Output?
>     I compile with "mcs --define DEBUG ...." but i don't know where the debug output 
> goes if it is being generated.
> 
> (I'm using Mono version 0.29 under Linux)
> 
> Thank you for your help.
> 
> G.
> 
> _______________________________________________
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list

_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to