Tem 3 itens que você precisa checar.
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- Seu Programa:
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();
}
}
Pronto :)
Código fonte do meu teste:
https://github.com/thiagoloureiro/Log4Net