I’m retro-fitting an older vb.net application to bring it into compliance with LUA principles in Vista. Up until now, the application has used a hodgepodge of logging mechanisms, but the core one involved writing a log to c:\temp\ if the folder existed. I want to replace this current logging with a more standard logging mechanism.
This being VB, I decided to try using My.Application.Log in conjunction with app.config, and that works as far as it goes (though I didn’t expect it to dump to the roaming profile). Unfortunately, the users are accustomed to troubleshooting with information from the log, as well as sending the log in when they submit a bug, and moving this log hides it pretty well.
My thought is to make the log a little more accessible by adding a link to it, or at least to the folder that contains it, in the app’s UI. I don’t know how to determine where that link will point, however.
Edit (Add’l info):
My configuration file is more or less the built-in default:
<system.diagnostics> <sources> <source name='Error Log' switchName='DefaultSwitch'> <listeners> <add name='FileLog'/> </listeners> </source> </sources> <switches> <add name='DefaultSwitch' value='Information' /> </switches> <sharedListeners> <add name='FileLog' type='Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' initializeData='FileLogWriter'/> </sharedListeners> </system.diagnostics>
I’d like to set some of the properties on the FileLogTraceListener in the config file. The MaxSize, e.g. (There was a prior max-size behavior). I don’t see any documentation that calls this out, though. (There is some community content at the base of the FileLogTraceListener page that suggests I should be able to, so I’ll check that. I’d be much more comfortable if I found some official documented support for this, though.)
If I do that, I ought to be able to iterate through the trace listener collection on My.Application.Log and just link to the first FileLogTraceListener’s FullLogFileName.
I believe this is configurable. It may be configured in the machine.config file, or you can override that in your application config file – which you will want to do so you can control it and create a link to it.
You will want to add a
FileLogTraceListenerto the app.config.It goes in the
system.diagnostics\sharedListenerssection. You can specify the filename in theinitializeDataattribute.More documentation from MSDN: