Setting up tracing in config file (windows form app)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Billingsley

    Setting up tracing in config file (windows form app)

    The documentation on this subject seems to give you 98% of what you need to
    know. From various sources, I have compiled an understanding that this
    should work:

    <configuratio n>
    <system.diagnos tics>
    <switches>
    <add name="clientswi tch" value="3" />
    </switches>
    <trace autoflush="true " indentsize="0">
    <listeners>
    <add name="traceList ener" type="System.Di agnostics.TextW riterTraceListe ner,
    system version=1.0.500 0.0, Culture=neutral ,
    PublicKeyToken= b77a5c561934e08 9" initializeData= "TraceLog.t xt" />
    </listeners>
    </trace>
    </system.diagnost ics>
    </configuration>

    (Pardon the formatting, hard to get it pretty with plain text ya know)

    When I execute this line in my code:
    Trace.WriteLine ("Starting client Form1");
    I get a ConfigurationEx ception which says "Couldn't find type for class
    System.Diagnost ics.TextWriterT raceListener, system version=1.0.500 0.0, "
    etc. (the whole fqn from the config file is shown).

    I can't find an actual fully working example on gotdotnet or msdn, and like
    I said the documentation just points you in the general direction but
    doesn't really give you the complete answer.

    Is there anybody that has this working and can give me some pointers?


  • José Joye

    #2
    Re: Setting up tracing in config file (windows form app)

    The version below works for me. It has the advantage to be .NET version
    independant :-)

    <trace autoflush="true " indentsize="4">
    <listeners>
    <!-- With the following line, you define the location where the
    tracing will
    be stored related to the LocalLogSwitch. To disable output,
    comment the next line -->
    <add name="BTListene r"
    type="System.Di agnostics.TextW riterTraceListe ner"
    initializeData= "C:\temp\BTFile Acquisition.log " />
    <remove type="System.Di agnostics.Defau ltTraceListener " />
    </listeners>
    </trace>

    José


    "Daniel Billingsley" <dbillingsley@N O.durcon.SPAAMM .com> wrote in message
    news:uFrPT6xkDH A.976@tk2msftng p13.phx.gbl...[color=blue]
    > The documentation on this subject seems to give you 98% of what you need[/color]
    to[color=blue]
    > know. From various sources, I have compiled an understanding that this
    > should work:
    >
    > <configuratio n>
    > <system.diagnos tics>
    > <switches>
    > <add name="clientswi tch" value="3" />
    > </switches>
    > <trace autoflush="true " indentsize="0">
    > <listeners>
    > <add name="traceList ener"[/color]
    type="System.Di agnostics.TextW riterTraceListe ner,[color=blue]
    > system version=1.0.500 0.0, Culture=neutral ,
    > PublicKeyToken= b77a5c561934e08 9" initializeData= "TraceLog.t xt" />
    > </listeners>
    > </trace>
    > </system.diagnost ics>
    > </configuration>
    >
    > (Pardon the formatting, hard to get it pretty with plain text ya know)
    >
    > When I execute this line in my code:
    > Trace.WriteLine ("Starting client Form1");
    > I get a ConfigurationEx ception which says "Couldn't find type for class
    > System.Diagnost ics.TextWriterT raceListener, system version=1.0.500 0.0, "
    > etc. (the whole fqn from the config file is shown).
    >
    > I can't find an actual fully working example on gotdotnet or msdn, and[/color]
    like[color=blue]
    > I said the documentation just points you in the general direction but
    > doesn't really give you the complete answer.
    >
    > Is there anybody that has this working and can give me some pointers?
    >
    >[/color]


    Comment

    • Daniel Billingsley

      #3
      Re: Setting up tracing in config file (windows form app)

      Thanks that seems to work!

      Several sections of the documentation state that the syntax for the listener
      includes the fully qualified name, and one section explains how you have to
      pull that from the GAC. I've found the .NET doc to be very good, but this
      topic needs some work. :)

      "José Joye" <jose.joye@KILL THESPAMSbluewin .ch> wrote in message
      news:ObrYl2ykDH A.2500@TK2MSFTN GP10.phx.gbl...[color=blue]
      > The version below works for me. It has the advantage to be .NET version
      > independant :-)
      >
      > <trace autoflush="true " indentsize="4">
      > <listeners>
      > <!-- With the following line, you define the location where the
      > tracing will
      > be stored related to the LocalLogSwitch. To disable output,
      > comment the next line -->
      > <add name="BTListene r"
      > type="System.Di agnostics.TextW riterTraceListe ner"
      > initializeData= "C:\temp\BTFile Acquisition.log " />
      > <remove type="System.Di agnostics.Defau ltTraceListener " />
      > </listeners>
      > </trace>
      >
      > José[/color]


      Comment

      • José Joye

        #4
        Re: Setting up tracing in config file (windows form app)

        I more than agree with you!
        It took me one year to get the version I have now :-((

        José
        "Daniel Billingsley" <dbillingsley@N O.durcon.SPAAMM .com> wrote in message
        news:%23N5%23zH zkDHA.4008@TK2M SFTNGP11.phx.gb l...[color=blue]
        > Thanks that seems to work!
        >
        > Several sections of the documentation state that the syntax for the[/color]
        listener[color=blue]
        > includes the fully qualified name, and one section explains how you have[/color]
        to[color=blue]
        > pull that from the GAC. I've found the .NET doc to be very good, but this
        > topic needs some work. :)
        >
        > "José Joye" <jose.joye@KILL THESPAMSbluewin .ch> wrote in message
        > news:ObrYl2ykDH A.2500@TK2MSFTN GP10.phx.gbl...[color=green]
        > > The version below works for me. It has the advantage to be .NET version
        > > independant :-)
        > >
        > > <trace autoflush="true " indentsize="4">
        > > <listeners>
        > > <!-- With the following line, you define the location where the
        > > tracing will
        > > be stored related to the LocalLogSwitch. To disable output,
        > > comment the next line -->
        > > <add name="BTListene r"
        > > type="System.Di agnostics.TextW riterTraceListe ner"
        > > initializeData= "C:\temp\BTFile Acquisition.log " />
        > > <remove type="System.Di agnostics.Defau ltTraceListener " />
        > > </listeners>
        > > </trace>
        > >
        > > José[/color]
        >
        >[/color]


        Comment

        Working...