Console trace and multiple program instances...

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

    #1

    Console trace and multiple program instances...

    At present I'm generating a log file during program execution by creating a
    console log trace and sending it to an external file thus:

    Debug.Listeners .Add(New TextWriterTrace Listener(Consol e.Out))
    Debug.Listeners .Add(New TextWriterTrace Listener(Applic ation.UserAppDa taPath
    + "\log.txt", "log file"))


    Now a good feature here is that if "log.txt" already exists and is in use
    (for example when I have multiple instances of the client running), the
    TextWriterTrace Listener automatically creates a unique filename and appends
    "log.txt" to the end of it, i.e.:
    "529f6441-14f6-4628-aead-cf6eea410c40log .txt". The problem though is that I
    don't know the name of the log file for the second instance, so I cannot
    implement a log file viewer within my application that reads anything other
    than the first instance ("log.txt"). I can't find a property on the
    TextWriterTrace Listener class that would tell me the path it is writing to.

    Perhaps it is using a per-instance GUID to generate the unique name. Can I
    access this GUID anywhere?


    Thanks,



    Robin



Working...