Add logging to ApplicationListener example

This commit is contained in:
Grzegorz Piwowarek 2016-08-14 08:18:10 +02:00
parent 24e033a24b
commit b759bf7c59
1 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package org.baeldung.startup;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
@ -7,10 +8,13 @@ import org.springframework.stereotype.Component;
@Component
public class StartupApplicationListenerExample implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger LOG = Logger.getLogger(StartupApplicationListenerExample.class);
public static int counter;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
LOG.info("Increment counter");
counter++;
}
}