[logback-user] have to cast logger to use logback specific api

Ceki Gulcu listid at qos.ch
Mon Apr 7 19:50:56 CEST 2008


Is the HelloWorld1 example you refer to, the one shown at [1]?

Anyway,  while it is true that you cannot set the logger level without casting 
to logback's native API, you can configure logback using a configuration script. 
Moreover, logback will automatically search for a configuration script called 
logback.xml (or logback-test.xml) in your class path.

Thus, in your Java code you can only reference the SLF4J API and configure the 
underlying logging system, namely logback, using an automatically loaded 
configuration script.

For more detailed information please see [2].

I hope this helps,

[1] http://logback.qos.ch/xref/index.html
[2] http://logback.qos.ch/manual/joran.html

dvd at newfoundmarket.com wrote:
> Hello:
> 
> I tried the Helloword1 example that comes with logback and noticed that 
> slf4j's Logger does not have methods such as logger.setLevel that 
> logback provides, in order to use it, I have to cast it to logback's 
> Logger.  I'd need to use those methods in app on the fly instead of use 
> a static config file.  But once I cast it, it means it would be tied to 
> logback and why bother with the slf4j at all? I mean once I do this way, 
> I can not do the deployment time switch to other logging lib.
> 
> What would be the recommended way to deal with my scenarios?
> 
> Thanks

-- 
Ceki Gülcü
QOS.ch is looking to hire talented developers in Switzerland.  If
interested, please contact c e k i @ q o s . c h




More information about the Logback-user mailing list