> -----Original Message-----
> From: Daniel Bachler [mailto:[EMAIL PROTECTED] 

[snip]

> Is there a possibility to get the reference to a certain 
> Appender that was created via config file magic? Something 
> similar to LogManager.GetLogger(), along the lines of 
> LogManager.GetAppenderByName(string name)? 

You can get all the appenders using:

LogManager.GetLoggerRepository().GetAppenders()

You will need to iterate through the list and find your named appender.


> My old, custom logging 
> framework had a function called SetJob(string currentJob) 
> that would output the string given to what is called the 
> appenders in log4net, but there would be special handling to 
> update a small label in the UI to inform the user of what the 
> app is currently doing.

If the "job" is metadata for the log events that occur then the job name
should be attached as a property to the logging events.
If your jobs run on a single thread then the easiest way to do this is
using the ThreadContext

void Job1()
{
  using(ThreadContext.Stacks["Job"].Push("job-name"))
  {
    ... statements and methods to perform job1
    ... any log statements here will have the Job property set to
'job-name'
  }
}


You can retrieve the value of the Job property by using the
LookupProperty method on the LoggingEvent object.

Cheers,
Nicko


Reply via email to