logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleš Vojáček <algid...@gmail.com>
Subject Re: Hi all - Resolved
Date Tue, 11 May 2010 13:01:02 GMT

this code works

            var appender = new FileAppender() {File = "pokus.log",
AppendToFile = false};
            appender.Layout = new log4net.Layout.PatternLayout("%date
[%thread] %-5level %type %logger - %message%newline");
            appender.Threshold = Level.Info;
            appender.ActivateOptions();

            Logger root = ((Hierarchy) LogManager.GetRepository()).Root;
            log4net.LogManager.GetRepository().ResetConfiguration();
            root.AddAppender(appender);
            root.IsEnabledFor(Level.Debug);
            root.Level = Level.Info;

            ILog pepa = LogManager.GetLogger("Pepa");
            Logger pepa_logger = pepa.Logger as Logger;
            pepa_logger.Level = Level.Debug;
           
            pepa_logger.Repository.Configured = true;           

            ILog logger = null;
            logger = log4net.LogManager.GetLogger("Pepa");
           
            logger.Debug("Debug zpravicka");
            logger.Fatal("Fatal zpravicka");
            logger.Info("Info zpravicka");



Aleš Vojáček napsal(a):
> Thank you for reply, but it does not help. :-(
>
> Best regards A.
>
> Radovan Raszka napsal(a):
>   
>> Try appender.ActivateOptions(), but I'm nor sure if it helps as you call Configure
after setting up the appender
>>
>> R 
>>
>> -----Původní zpráva-----
>> Od: Aleš Vojáček [mailto:algidovo@gmail.com] 
>> Odesláno: 11. května 2010 11:10
>> Komu: log4net-user@logging.apache.org
>> Předmět: Hi all
>>
>> I have some problems with set up IsDebugEnabled to false by code.
>>
>>             var appender = new ConsoleAppender();
>>             appender.Layout = new log4net.Layout.PatternLayout("%date
>> [%thread] %-5level %type %logger - %message%newline");
>>             appender.Threshold = Level.Info;
>>
>>             log4net.Filter.DenyAllFilter f = new DenyAllFilter();
>>             appender.AddFilter(f);
>>
>>             log4net.Filter.LevelRangeFilter filter = new log4net.Filter.LevelRangeFilter();
>>             filter.LevelMin = Level.Info;
>>             filter.LevelMax = Level.Fatal;
>>             appender.AddFilter(filter);
>>             log4net.Config.BasicConfigurator.Configure(appender);
>>             var logger = log4net.LogManager.GetLogger("Main");
>>
>>
>> logger.IsDebugEnabled is still set to true :-(
>>
>> Can someone help me with that?
>> A.
>>
>>   
>>     
>
>
>   


Mime
View raw message