You cannot cast it. But if you instantiate the commons Logger with the same 
name as your log4j logger your log statements will end up in the same logger 
instance (log4j Logger). Commons logging is only a wrapper, and instantiates 
log4j if it finds a log4j.jar in the classpath (and not configured otherwise).
If you do not need special functionality of log4j interface which is not 
covered by commons-logging, I recommend that you replace the existing logger in 
your calling class by an instance of commons-logging Logger and use this 
instance to pass to the library and use for logging in the calling class.
Heri 

-----Ursprüngliche Nachricht-----
Von: rouble [mailto:rou...@gmail.com] 
Gesendet: Mittwoch, 28. Oktober 2009 14:59
An: log4j-user@logging.apache.org
Betreff: convert org.apache.log4j.Logger to org.apache.commons.logging.Log

Hi All,

The class I am working in has org.apache.log4j.Logger object, and I am working 
with a third party library class that requires me to pass in a 
org.apache.commons.logging.Log object to create an instance of the factory 
object of that third party library.

The third party library uses the passed in Log object to send logs directly to 
the same logger/logfile as the calling class. Note, that I cannot change the 
third party library, but I do have access to org.apache.commons.logging.Log in 
my own code.

I was wondering if it is possible to cast or convert a org.apache.log4j.Logger 
to a org.apache.commons.logging.Log, or if I need to create a new Log object 
and pass that in to the third party library?

tia,
rouble

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to