On Wed, Apr 8, 2009 at 11:33 AM, omatase <omat...@gmail.com> wrote:

>
>
>
> Daniel Marohn wrote:
> >
> > Hi!
> >
> > ...
> > Someone else might have an application that they would like to send
> > DEBUG messages to the FileAppender
> > even though my application may only send FATAL
> > ...
> >
> > this is, why you have different logger.
> > from your first post:
> >
> > <logger name="Invoicing">
> > ...
> > </logger>
> >
> > <logger name="Invoicing">
> > ...
> > </logger>
> >
> >
>
> Yes, that *is* why I am doing that
>
>
> Daniel Marohn wrote:
> >
> >
> > this makes no sense. You configure the logger 'Invoicing' and later
> > you configure the SAME logger with different properties. How do you
> > want to access these 'two' loggers from your code?
> > LogManger.GetLogger("Invoicing, but please first version") ? ;-)
> >
>
> log4net is intelligent enough to handle this.
>
> When you call :
>
> log4net.LogManager.GetLogger(loggerName).Debug(message, exception);
> or
> log4net.LogManager.GetLogger(loggerName).Error(message, exception);
>
> It will use the logger defined with value="DEBUG"
>
> But, when you call
>
> log4net.LogManager.GetLogger(loggerName).Fatal(message, exception);
>
> log4net will use the logger defined with value="FATAL"
>
> This allows me to use the same loggerName throughout my application, and
> have FATAL messages logged in a different manner. FATAL messages are more
> urgent and require immediate attention for this I will be using an
> SnmpAppender that will send the messages directly to our critical problem
> monitoring system.
>
>
> Daniel Marohn wrote:
> >
> > You can do this:
> >
> >   <appender name="consoleTestAppender"
> > type="log4net.Appender.ConsoleAppender" >
> >     <layout type="log4net.Layout.PatternLayout">
> >       <conversionPattern value="%date %-5level %logger -
> %message%newline"
> > />
> >     </layout>
> >   </appender>
> >
> > <logger name="Invoicing.Application1">
> >  <level value="ERROR" />
> >  <appender-ref ref="consoleTestAppender" />
> > </logger>
> >
> > <logger name="Invoicing.Application2">
> >  <level value="WARN" />
> >  <appender-ref ref="consoleTestAppender" />
> > </logger>
> >
> > now you have two different loggers  (one for each app), using the same
> > appender. And you can set the Level per Logger.
> >
> >
>
> The invoicing application is a single application. If I were to define
> multiple loggers with different names I might do something like this
> instead:
>
> <logger name="Invoicing.Logger1">
>  <level value="FATAL" />
>  <appender-ref ref="consoleTestAppender" />
> </logger>
>
> <logger name="Invoicing.Logger2">
>  <level value="WARN" />
>  <appender-ref ref="consoleTestAppender" />
> </logger>
>
> The problem here is I am trying to send my critical errors to Snmp, so in
> my
> code I would have to remember the logger name I am using for critical
> errors
> (in this case Invoicing.Logger1). It is much simpler to just have to
> remember to call ".Fatal" when I have a critical error and not have to
> remember the loggername that was meant to handle fatal errors.
>
> --
> View this message in context:
> http://www.nabble.com/Error-destroying-my-productivity-Please-Help%21%3A-log4net%3AERROR----Attempted-to-append-to-closed-appender-named----tp22939427p22953058.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>

Reply via email to