logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4NET-283) OnlyOnceErrorHandler is not subclass-friendly
Date Thu, 08 Sep 2011 08:21:10 GMT

     [ https://issues.apache.org/jira/browse/LOG4NET-283?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Stefan Bodewig updated LOG4NET-283:
-----------------------------------

      Component/s:     (was: Appenders)
                   Core
    Fix Version/s:     (was: 1.2.11)
                   1.2 Maintenance Release
       Issue Type: Improvement  (was: Bug)
          Summary: OnlyOnceErrorHandler is not subclass-friendly  (was: ErrorHandler does
not work with custom class)

> OnlyOnceErrorHandler is not subclass-friendly
> ---------------------------------------------
>
>                 Key: LOG4NET-283
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-283
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.2.10
>         Environment: Windows 7, IIS 7, .Net 3.5, C#
>            Reporter: Randar Puust
>             Fix For: 1.2 Maintenance Release
>
>
> If you ever try to use the ErrorHandler attribute with a custom error handler, it won't
write out the messages.  For example:
>   <appender name="Database_Appender" type="log4net.Appender.AdoNetAppender">
>    <errorHandler type="CHO.Next.Global.LogWriterErrorHandler, CHO.Next.Global" />
> Where the class is defined as:
>     public class LogWriterErrorHandler : OnlyOnceErrorHandler
>     {
>         
>         public new void Error(string message)
>         {
>             Error(message, null);
>         }
>         public new void Error(string message, Exception e)
>         {
>             Error(message, e, ErrorCode.GenericFailure);
>         }
>         public new void Error(string message, Exception e, ErrorCode errorCode)
>         {
>           // write to a file here
>          }
>      }
>      
> This was specified as a fix on a few posts like this http://www.mail-archive.com/log4net-user@logging.apache.org/msg04378.html
and there hasn't been anything to correct it.
> The reason this won't work is that Error is not virtual.  Although the LogWriterErrorHandler
is instantiated and the constructor is called, when the appender makes a call to this.ErrorHandler.Error,
it calls the base class of OnlyOnceErrorHandler and not LogWriterErrorHandler.  
> I would recommend you make the Error methods in AppenderSkeleton virtual so that they
can be overriden.  Otherwise, what is the value of even having the ErrorHandler attribute
available on the appender?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message