Add logging to ApplicationListener example
This commit is contained in:
parent
24e033a24b
commit
b759bf7c59
|
@ -1,5 +1,6 @@
|
||||||
package org.baeldung.startup;
|
package org.baeldung.startup;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -7,10 +8,13 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class StartupApplicationListenerExample implements ApplicationListener<ContextRefreshedEvent> {
|
public class StartupApplicationListenerExample implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(StartupApplicationListenerExample.class);
|
||||||
|
|
||||||
public static int counter;
|
public static int counter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
|
LOG.info("Increment counter");
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue