Sunday, November 23, 2008
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Change the logging directory at runtime
Prev Next
You are not authorized to post a reply.

Author Messages
Freddy Gómez

07/29/2008 8:58 PM  
Hi,

I'm planning to use log4net to write events in a removable usb memory.

As you can suppose I have problems setting the right path for the logging file in the removable drive, there is no warranty about the drive where the memory will be mounted each time; and the application, depending on its state, it can be using different removable memories at different times.

I wonder if there is any way of setting the file path of the FileAppender or RollingFileAppender at runtime.

Thanks in advance,

Freddy.
Rennie Petersen

07/29/2008 9:26 PM  
This may not be the best method, but it is possible to modify the log4net.config.xml file at runtime.
 
This requires that you have used the ConfigureAndWatch method of configuring log4net.
 
Rennie
 
Josh Kewley

07/31/2008 7:08 PM  

I wrote a post on this a long time ago:

http://insario.com/blog/jfk/archive/2004/11/30/164.aspx

it’s dated, but you may be able to use it as a starting point.

-Josh

 

Freddy Gómez

07/31/2008 9:21 PM  
Thanks Rennie, your solution will get in the list of options.

Fred.

Freddy Gómez

07/31/2008 9:35 PM  
Thanks Josh, that's the kind of solution I'm looking for.

However I need to go a step beyond because I need several appenders logging in several directories (all of them set at runtime).

What I gonna do is to create an appender (subclassing RollingFileApplender) with a parameter which will be a class who implement a property 'LogDirectory' (As your 'Web.WebEnvironment.LogDirectory') and then create a class who return its own directory to each appender. If I do it well all the configuration needed will be placed in the configuration file.

I'll post again If I have success.

-Fred
You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Change the logging directory at runtime



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement