Archive for September 8th, 2010

08
Sep
10

Changing log4net log file path via code

Sometimes we might have to place the log files away from the location where the application is installed. And lo there is an option to do that! In the config file create a variable like below

<file type="log4net.Util.PatternString" value="%property{SomeVariable}log.txt" />

And in the code, before calling log4net configure, set the new path to the Variable

log4net.GlobalContext.Properties["SomeVariable"] = YourNewPath;
log4net.Config.XmlConfigurator.Configure();

Simple isn’t it Smile




@pooran

 

September 2010
M T W T F S S
« Aug   Nov »
 12345
6789101112
13141516171819
20212223242526
27282930  

Visits so far..

  • 10,471

Follow

Get every new post delivered to your Inbox.