Here is the code to do exactly what you want:

Hierarchy hierarchy;

if((hierarchy = (Hierarchy)
LogManager.GetLoggerRepository()) != null )
{
    FileAppender  fileAppender          = new FileAppender();

    PatternLayout patternLayout         = new
PatternLayout();

    string                logFile       = string.Format(
@"{0}\myLogFile.log", myLogDir );
    string                logThreshold  = "DEBUG"; // whatever you
want here...

    patternLayout.Header                = "[Begin]\r\n";
    patternLayout.Footer                = "[End]\r\n\r\n";
    patternLayout.ConversionPattern     = "%d [%t] %-5p
%c - %m%n";

    fileAppender.Name                   = config.myAppenderName;
    fileAppender.File                   = logFile;
    fileAppender.AppendToFile           = true;
    fileAppender.ImmediateFlush         = true; // IMPORTANT
    fileAppender.Layout                 = patternLayout;
    fileAppender.Threshold              = Level.DEBUG;

    fileAppender.ActivateOptions();

    log4net.Config.BasicConfigurator.Configure(
fileAppender );
}





--- "Wirun, Corey" <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> Is it possible with 1.2.0 beta8 (.Net Framework 1.1)
> to change the
> FileAppender log file at runtime (versus getting it
> from my config file and
> using it from that point on)?
> 
> I've got an ASP.NET application calling my assembly
> on the backend and I
> want to generate log files (when enabled) with a
> name based on something
> from the session information.
> 
> Thanks in Advance!
> Corey.
> 
> -----
> Corey MJ Wirun, B.Sc.
> AspenTech Canada, Ltd. Calgary Alberta 
> home office: 403 720-3699 fax: 403 720-3699 (shared
> line, voice call ahead!)
> "Anything will fly with 10KLbs of thrust.  Landing? 
> That's a different
> story." - power does not mean capability.
>  
> 



        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

Reply via email to