1

I am wanting to inject a org.slf4j.Logger into classes that need it instead of declaring it as static at the top and specifying the class name eg.

private static final Logger log = LoggerFactory.getLogger(Application.class);

To do so I have created a producer method like so

@Produces
public Logger getLogger(InjectionPoint injectionPoint)
{
    return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}

And then I inject it using @Inject but it only seems to do inject for the first class that requests it, all other classes that have a org.slf4j.Logger injection point end up with a NPE

PDStat
  • 5,513
  • 10
  • 51
  • 86

0 Answers0