How do I get google guice to inject a custom logger, say a commons-logging or log4j logger

Posted by Miguel Silva on Stack Overflow See other posts from Stack Overflow or by Miguel Silva
Published on 2010-04-09T05:09:45Z Indexed on 2010/04/09 5:13 UTC
Read the original article Hit count: 454

Google guice has a built-in logger binding (http://code.google.com/p/google-guice/wiki/BuiltInBindings). But what if I want to use a commons-logging or log4j logger?

Can I get guice to inject a Log created by

LogFactory.getLog(CLASS.class)

But having the same behavior as in built-in binding:

The binding automatically sets the logger's name to the name of the class into which the Logger is being injected..


Does it even makes sense? Or shout I simply use the built-in java Logger? Or just use commons-logging without injections?

© Stack Overflow or respective owner

Related posts about guice

Related posts about java