logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: ~/MyLogFile.txt
Date Sat, 25 Mar 2006 00:59:39 GMT
In addition to the other suggestions, you could do this:

public class TildaFileAppender : FileAppender
{
 public override string File
 {
  get
  { 
   return base.File; 
  }
  set
  { 
   // replace the tilda with whatever value you want
   base.File = value.Replace(
    "~", 
   AppDomain.CurrentDomain.SetupInformation.ApplicationBase); 
  }
 }
}

You can also register your own patterns. The "appSettings" pattern
would get a value from AppSettings:

 <file value="%appSettings{LogDirectory}/MyLogFile.log"/>

Or you could create a pattern that gets the logging directory some
other way:

 <file value="%loggingDir/MyLogFile.log"/>

--- Morten Andersen <morten@vianett.no> wrote:

> Hi
> 
> It would have been grate to be able to configure the logging
> directory 
> for my application, for example, in a environment variable.
> 
> Before:
>             <file value="c:/LogFiles/log4net/MyLogFile.log"/>
> 
> After:
>             <file value="~/MyLogFile.log"/>
> 
> -- 
> 
> Best Regards
> *Morten Andersen*
> Developer
> Vianett AS <http://www.vianett.no/> | morten@vianett.no 
> <mailto:morten@vianett.no> | Office: +47 69 20 69 74 
> <callto://+4769206974> | Skype: mortander <callto://mortander>
> 
> 


Mime
View raw message