Fetching the log filename

Topics: Logging Application Block
Jul 6, 2009 at 3:15 PM

Hi,

I have configured the filename of the log file to which the logs have to be written to in the Ent Lib Editor. I would like to know, if I can fetch the configured file name programmatically from within my code? If yes, how?

Your help is appreciated.

Thank You,

-Bhaskar

 

Jul 7, 2009 at 4:22 AM

Configuration config = ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
LoggingSettings loggingSettings = (LoggingSettings)config.GetSection(LoggingSettings.SectionName);
FlatFileTraceListenerData flatfiletracedata = loggingSettings.TraceListeners.Get("FlatFile TraceListener") as FlatFileTraceListenerData;
//access the filename using flatfiletracedata .Filename

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com

Jul 7, 2009 at 7:56 AM

Hi Sarah,

Thanks for your reply. However, I intend to use this code in VC++. Can you please let me know the namespaces that needs to be used for this?

Thanks in advance,

-Bhaskar

 

Jul 7, 2009 at 8:33 AM

Add references to System.Configuration, Microsoft.Practices.EnterpriseLibrary.Logging assemblies.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

entlib.support@avanade.com

Jul 7, 2009 at 11:27 AM

Hi Sarah,

Thanks a lot for your responses. It sure did help me.

Cheers,

-Bhaskar