Allows to configure Log4net as Microsoft Extensions Logging handler on any .NET Core application.
Thanks to @anuraj for this original blog post.
-
Install the package or reference the project into your .net core application.
-
Add the
AddLog4Net()
call into yourILoggerFactory
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.
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.