Skip to content

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

jenseralmeida/ElmahAppender.log4net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElmahAppender.log4net

NuGet

This package is a fork of https://github.com/edwinf/log4net---ELMAH-Appender and all the code was implemented by the original author. This package only modernize the .net stack of the original one.

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.

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.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%