Log4net has stopped showing the logs

2

My console has stopped displaying the nothing logs, I've compiled it several times and it never happened to me, just now

Code:

    public static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

log.Info("Hello World")

Hello World does not appear, but if I do Console.WriteLine ("Hello World") appears on the console, what can it be? I wanted the log.Info to reappear.

Could it be a bug?

Sometimes only the log.error appears:

    
asked by anonymous 13.11.2017 / 19:03

1 answer

0

You have 3 items that you need to check out.

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 :)

Testsourcecode:

link

    
14.11.2017 / 00:25