Skip to content

nalla/Extensions.Logging.Log4Net

Repository files navigation

Extensions.Logging.Log4Net

Allows to configure Log4net as Microsoft Extensions Logging handler on any .NET Core application.

Thanks to @anuraj for this original blog post.

NuGet Build status

Example of use

  • Install the package or reference the project into your .net core application.

  • Add the AddLog4Net() call into your ILoggerFactory configuration method.

serviceCollection.AddLogging(builder => builder
	.AddLog4Net()
	.SetMinimumLevel(LogLevel.Debug));
  • Add a log4net.config file with the content:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="DebugAppender" type="log4net.Appender.DebugAppender" >
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="ALL"/>
    <appender-ref ref="DebugAppender" />
  </root>
</log4net>

You can found more configuration examples on configuration documentation.

Special thanks

Thank you very much to all contributors & users by its collaboration, and specially to:

  • @huorswords by his great job on the aspnetcore variant which was the base of this package.

About

Extends the Microsoft logging extensions with log4net support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published