[logback-user] Enable Debugging Mode Programmatically?

Jack Vinijtrongjit juminoz at hotmail.com
Tue Dec 13 23:41:27 CET 2011


Thanks guys.
Both suggestions actually didn't work for me. I tried with obvious configuration that is supposed to log some error message such as not setting RollingPolicy to a RollingFileAppender and it's still not printing anything out at all.
    if (rollingPolicy == null) {
      addError("No RollingPolicy was set for the RollingFileAppender named "
          + getName());
      addError("For more information, please visit "+CODES_URL+"rfa_no_rp");
      return;
    }
I traced through and addError() method invoking addStatus() method in ContextAwareBase, which the invokes StatusManager. It looks like BasicStatusManager has log level set to INFO level by default so these error messages should have really shown up.
I still can't get RollingFileAppender to work and it would great to see why it doesn't work.
Thanks,Jack

From: onlymed at hotmail.com
To: logback-user at qos.ch
Date: Tue, 13 Dec 2011 22:20:34 +0100
Subject: Re: [logback-user] Enable Debugging Mode Programmatically?








Hello Andrew, 

For the root level you can do something like this : 

((Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.toLevel("DEBUG"));


> From: andrew.bourgeois at hotmail.com
> To: logback-user at qos.ch
> Date: Tue, 13 Dec 2011 21:42:25 +0100
> Subject: Re: [logback-user] Enable Debugging Mode Programmatically?
> 
> Hello Jack
> 
> I don't know how to do it for the rootLogger, but here's how I did enable a 
> debug level for my whole app:
> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
> lc.getLogger("be.mydomain.testapp").setLevel(Level.DEBUG);
> 
> Using the following imports:
> import org.slf4j.LoggerFactory;
> import ch.qos.logback.classic.Level;
> import ch.qos.logback.classic.LoggerContext;
> 
> If anyone knows how to do it for the rootLogger, please let me know (as it 
> can be annoying to enable debug logs for every package of the 
> dependencies...).
> 
> Best regards
> 
> Andrew
> 
> -----Original Message----- 
> From: juminoz
> Sent: Tuesday, December 13, 2011 12:14 AM
> To: logback-user at qos.ch
> Subject: [logback-user] Enable Debugging Mode Programmatically?
> 
> 
> I was wondering if there is a way to enable debug mode programmatically.
> Since I'm not allowed to use configuration file, I'm currently configure
> everything programmatically. Recently, I ran into an issue where
> RollingFileAppender stop writing to file though FileAppender works perfectly
> fine. In fact, RollingFileAppender was also working last week and nothing
> that I'm aware of has changed since.
> 
> Please let me know if there is a way to enable debug since doing it using
> configuration file (logback.xml) doesn't seem to be working.
> 
> Thanks,
> Jack
> -- 
> View this message in context: 
> http://old.nabble.com/Enable-Debugging-Mode-Programmatically--tp32961424p32961424.html
> Sent from the Logback User mailing list archive at Nabble.com.
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user 
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
 		 	   		  

_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20111213/01f29ca0/attachment.html>


More information about the Logback-user mailing list