Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enterprise library logging block...Get log filename

Status
Not open for further replies.

PGoRule

Programmer
Jul 26, 2006
438
IN
Hi,
I am using Enterprise library 3.1 logging block with C# and framework 2.0. I have a listner configured for writing log to flat file. The settings for this is configured in app.config as follows:

Code:
<add fileName="D:\log\trace.log" header="----------------------------------------"
          footer="----------------------------------------" formatter="Text Formatter"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          traceOutputOptions="Timestamp" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          name="FlatFile TraceListener" />

Is there any way to access the fileName ("D:\log\trace.log") provided in this config file in the application?
I want to change the filename if it exceeds to some filesize limit.

Thanks a lot,
Prashant

Sharing the best from my side...

--Prashant--
 
rolling log files. i would recommend a different logging library like log4net or nlog. this feature is already built in. I also believe net lib 4 logging 4 has rolling log files. I stopped using ent lib last year so I'm not up to speed on the current feature set.

otherwise you need to parse the logging configs into a separate file, and use modify/overwrite the file regularly. this will also require you to create a service to monitor the file size. finally when the file is modified the application will be reset because a web.config dependency changed. this will cause errors for users who are using the site when the update occurs. I would consider this a hack on the logging framework.

finally you could roll your own logging extension to ent.lib. which would allow for rolling files.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
OK...I understood the problem.
I will try to look into other libraries. if they satisfy other requirements then certainly I will go for it.
Thanks a lot for your valuable words.


Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top