Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

This appender will allow log4net to be configured to send log messages to ELMAH directly. This way ELMAH can be the log manager of record for sites while still allowing specific logging parameters to be controlled with log4net as usual.

Notifications You must be signed in to change notification settings

edwinf/log4net---ELMAH-Appender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log4net---ELMAH-Appender

This appender will allow log4net to be configured to send log messages to ELMAH directly. This way ELMAH can be the log manager of record for sites while still allowing specific logging parameters to be controlled with log4net as usual.

Sample Log4net config:


<log4net>
    <appender name="elmahappender" type="elmahappender_log4net.ELMAHAppender, elmahappender_log4net">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [thread] %-5level %logger - %message%newline" />
      </layout>
      <UseNullContext>False</UseNullContext>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="elmahappender" />
    </root>
  </log4net>
  

My elmah config:


  <elmah>
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="connString" applicationName="TTDev" />
  </elmah>
  

For the sql error log, I had to put the application name on the config. For v1 I could not figure out how to pass the application name through the log4net log, it would ignore what I passed as the app name and just insert an empty string. The application not matching caused the display handler to not display those log entries. Setting the application name in the configuration entry above solved that problem.

This problem did not present itself with the in memory log.

New for 1.0.2: A new setting was also added called UseNullContext. This is used when you want to initialize the logger outside of a HTTP request (such as application start).
Please see this issue for more details.

Note: A second nuget package was created with the dependancy for log4net dropped to 1.2.10 and .Net 2.0. There were complications getting both 1.2.10 and 1.2.11 dependencies to work in the same package. That second package can be found Here

About

This appender will allow log4net to be configured to send log messages to ELMAH directly. This way ELMAH can be the log manager of record for sites while still allowing specific logging parameters to be controlled with log4net as usual.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages