-
Notifications
You must be signed in to change notification settings - Fork 2
@InjectLogger
excilys edited this page Mar 22, 2011
·
5 revisions
Feed up with copy/pasting (and sometimes forgetting to change MyClass) to declare a slf4j logger?
private Logger logger = LoggerFactory.getLogger(MyClass.class)Just follow these 2 steps :
1° Annotate your logger
@InjectLogger
private Logger logger;2° Declare the BeanPostProcessor into your Spring context :
<bean class="com.excilys.utils.spring.log.slf4j.BeanWithLogger" />or
<import resource="classpath:context/applicationContext-spring-log.xml" />As the logger is injected after the target bean is instanciated, don't try to log anything in constructors... In this case, revert to manual instanciation.