There are 3 items you need to check.
1- App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
2- Assemblyinfo.Cs
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
3- Your Program:
public static class Program
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
static void Main(string[] args)
{
log.Error("Hello World");
log.Warn("Hello World");
log.Info("Hello World");
Console.ReadLine();
}
}
Ready :)
Source code of my test:
https://github.com/thiagoloureiro/Log4Net
There must be some configuration missing there in your app, I put detailed in my reply.
– Thiago Loureiro