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

Gerweck Andy - agerwe Andy.Gerweck at acxiom.com
Mon Apr 7 20:03:00 CEST 2008


There are some additional features & design patterns that might help you out, but it's hard to go too far into them when we don’t know your use case.

 

In particular, why don’t you want to use a file for your configuration? What situation requires that you modify the logging levels from inside your code? This isn’t really a great thing to do: much of the usefulness of logging systems is the ability to change the configuration without rewriting the application.

 

Without more information, I’d suggest you look at the JMX configuration <http://logback.qos.ch/jmxConfig.html>  system and writing filters <http://logback.qos.ch/manual/filters.html> . These features help make a file-based configuration less static than it seems.

 

Thanks,

 Andy

 

-----Original Message-----
From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On Behalf Of Ceki Gulcu
Sent: Monday, April 07, 2008 10:51 AM
To: logback users list
Subject: Re: [logback-user] have to cast logger to use logback specific api

 

 

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

 

_______________________________________________

Logback-user mailing list

Logback-user at qos.ch

http://qos.ch/mailman/listinfo/logback-user

***************************************************************************
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be legally
privileged.

If the reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank You.
****************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20080407/3c2753d4/attachment.htm 


More information about the Logback-user mailing list