This is the patch that we use in Sisu (Sonatype's patched version of Guice) to allow the injection of SL4J and JUL loggers.
http://code.google.com/p/google-guice/issues/detail?id=492 Github repo is here: http://github.com/sonatype/sisu-guice On Sep 24, 2010, at 5:46 AM, Asier wrote: > Hi > > I've followed instructions from > > http://glauche.de/2009/08/24/logging-with-slf4j-and-guice/ > > To inject loggers via @InjectLogger tags, but this loggers are only available > after the constructor has been executed. > > class A { > > @InjectLogger private Logger logger; > private final SomeClass someClass; > > @Inject > A(SomeClas someClass) implements IA { > logger.debug("Initializing A"); > this.someClass = someClass; > } > > // ... > } > > Fails with a: > > | com.google.inject.CreationException: Guice creation errors: > | > | 1) Error injecting constructor, java.lang.NullPointerException > | ... > > How can I have a logger injected and usable in the constructor? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > Thanks, Jason ---------------------------------------------------------- Jason van Zyl Founder, Apache Maven http://twitter.com/jvanzyl --------------------------------------------------------- A man enjoys his work when he understands the whole and when he is responsible for the quality of the whole -- Christopher Alexander, A Pattern Language Thanks, Jason ---------------------------------------------------------- Jason van Zyl Founder, Apache Maven http://twitter.com/jvanzyl --------------------------------------------------------- We all have problems. How we deal with them is a measure of our worth. -- Unknown -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
