4

I'm using TextWriterTraceListener in my application, if file is not available to write trace, it create another trace file with GUID prefix.

All I'm interested is to get the trace file name. In normal condition, I know what would be the filename, but when TextWriterTraceListener prefixes the GUID, how do I predict/get the trace file name?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Prashant Cholachagudda
  • 13,012
  • 23
  • 97
  • 162

2 Answers2

0

I think TextWriterTraceListener has a private method called fileName. I used the debugger's immediate window to test the following:

l.Name;
"textFileListener"
l.fileName;
"C:\\Tools\\Support\\PatchInstaller\\bin\\Debug\\trace.txt"

I can't find a way to access that private method fileName. I tried inherit from TextWriterTraceListener but could not see that method. The only way so far is to use the Debugger.

Check out using .Writer property in this post.

Community
  • 1
  • 1
Hil Liao
  • 1
  • 1
0

TextWriterTraceListener has a Name property, isn't it what you are looking for?

EDIT
I tried to access the information you need but without success, mainly because the SystemDiagnosticsSection class that contains the app.config informations is inaccessible. I think your only chance is to parse the XML of the app.config or to use reflections to access some inner field of the object (which I'd not recommend).

Simone
  • 11,655
  • 1
  • 30
  • 43
  • No really! It is kind of identifier for Trace. To be more specific I'm looking for `initializeData` (Ref: http://msdn.microsoft.com/en-us/library/d1ckdta4(v=VS.90).aspx) – Prashant Cholachagudda Jun 03 '11 at 11:17