You'd have to write your own ILog too. If you aren't going to be extending the MyLogImpl class, you could make it sealed and make the methods non-virtual for a speed boost.
--- Ron Grabowski <[EMAIL PROTECTED]> wrote: > You may have already found this the archives, but this is a post > where > Nicko talks about reassigning log levels: > > http://tinyurl.com/c6p94 > http://www.mail-archive.com/log4net-user%40logging.apache.org/msg01678.html > > " > In 1.2.9 changes were made to the LogImpl class to support rebinding > levels in the config file at runtime. This is not the most obvious > feature, but it is actually possible, although not advisable, to swap > the DEBUG and ERROR levels at runtime. The ReloadLevels method was > added > to allow the LogImpl to keep up with any changes made to levels > during > configuration. The TraceLogImpl overrides the ReloadLevels method to > add > the TRACE level, while this is correct behaviour, it is not necessary > if > you don't intend to reconfigure your levels at runtime. > " > > I don't know how to rebind the default levels at runtime. Becuase > you're wanting to add additional levels too, it may be easier to > write > your own LogManager and use the following class as your ILog > implementation (I may have accidently switched the order of the > levels): > > // untested > public class MyLogImpl : LoggerWrapperImpl, ILog > { > private readonly static Type ThisDeclaringType = typeof(LogImpl); > > // 100, 200, 300, etc. for more flexibility ??? > private Level all = new Level(0, "ALL"); > private Level info = new Level(1, "VERBOSE"); > private Level debug = new Level(2, "DEBUG"); > private Level trace = new Level(3, "TRACE"); > private Level warn = new Level(4, "WARN"); > private Level error = new Level(5, "ERROR"); > private Level fatal = new Level(6, "FATAL"); > private Level info = new Level(7, "INFO"); > private Level off = new Level(8, "OFF"); > > public MyLogImpl(ILogger logger) : base(logger) > { > // caution: this implementation does not listen for config changes > } > > virtual public void Verbose(object message) > { > Logger.Log(ThisDeclaringType, verbose, message, null); > } > > virtual public void Debug(object message) > { > Logger.Log(ThisDeclaringType, debug, message, null); > } > > virtual public void Trace(object message) > { > Logger.Log(ThisDeclaringType, trace, message, null); > } > > // snip > > virtual public bool IsVerboseEnabled > { > get { return Logger.IsEnabledFor(verbose); } > } > > virtual public bool IsDebugEnabled > { > get { return Logger.IsEnabledFor(debug); } > } > > virtual public bool IsTraceEnabled > { > get { return Logger.IsEnabledFor(trace); } > } > > // snip > > } > > --- Hollywood <[EMAIL PROTECTED]> wrote: > > > And before it's asked, here is the *exact* order of logging that is > > in the > > requirements I am working with: > > > > ALL > > VERBOSE > > DEBUG > > TRACE > > WARN > > ERROR > > FATAL > > INFO > > OFF > > > > which differsn from the standard listed in the log4net > documentation > > of: > > > > ALL > > DEBUG > > INFO > > WARN > > ERROR > > FATAL > > OFF > > > > ----- Original Message ----- > > From: "Ron Grabowski" <[EMAIL PROTECTED]> > > To: "Log4NET User" <[email protected]> > > Sent: Wednesday, July 06, 2005 12:11 PM > > Subject: Re: Configuration of Levels > > > > > > >I can't think of a good reason why someone would want to make WARN > > more > > > serious than FATAL. Wouldn't that make it difficult for future > > > maintainers? > > > > > > Perhaps you could write your own Logger implementation and have > it > > > internally mix-up values as you see fit: > > > > > > DEBUG -> DEBUG > > > WARN -> INFO > > > ERROR -> WARN > > > FATAL -> ERROR > > > INFO -> FATAL > > > > > > --- Hollywood <[EMAIL PROTECTED]> wrote: > > > > > >> I'll clarify my original question: > > >> > > >> Has the configuration of logging Levels ORDER been implemented > > yet > > >> or is it > > >> still static, i.e. being able to say that the logging level is > > >> VERBOSE, > > >> DEBUG, WARN, ERROR, FATAL, TRACE, INFO rather that what has been > > >> hardcoded > > >> into the log4* system? > > >> > > >> ----- Original Message ----- > > >> From: "Ron Grabowski" <[EMAIL PROTECTED]> > > >> To: "Log4NET User" <[email protected]> > > >> Sent: Wednesday, July 06, 2005 11:18 AM > > >> Subject: Re: Configuration of Levels > > >> > > >> > > >> > There has been example code in CVS since January 2004: > > >> > > > >> > http://tinyurl.com/9atgc > > >> > > > >> > > > > > > http://cvs.apache.org/viewcvs.cgi/logging-log4net/examples/net/1.0/Extensibility/TraceLogApp/cs/src/TraceLogApp.cs?rev=1.3&view=log > > >> > > > >> > I think it was possible with 1.2.0 beta 8 which means its > > existed > > >> since > > >> > at least 2003. > > >> > > > >> > --- Hollywood <[EMAIL PROTECTED]> wrote: > > >> > > > >> >> Has the configuration of logging Levels been implemented yet? > > Or > > >> is > > >> >> it still > > >> >> static? > > >> >> > > >> >> > > >> > > > >> > > > >> > > > >> > > >> > > > > > > > > > > > > > > >
