I'm running a Vaadin Servlet with a very simple code and I want to log with Log4j when the application starts/ends, and the same for the sessions of the clients. However, only some of the messages that are logged end up being written on the log file itself.
The code of the servlet is the following:
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "som.vaadin.AppWidgetSet")
public static class Servlet extends VaadinServlet implements SessionInitListener, SessionDestroyListener {
private static final Logger LOGGER = LogManager.getLogger(Servlet.class);
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
LOGGER.info("App started");
getService().addSessionInitListener(this);
getService().addSessionDestroyListener(this);
}
@Override
public void destroy() {
LOGGER.info("App stopped");
super.destroy();
}
@Override
public void sessionInit(SessionInitEvent event) {
LOGGER.info("Session started");
}
@Override
public void sessionDestroy(SessionDestroyEvent event) {
LOGGER.info("Session expired");
}
}
My log4j log configuration file is the following:
log4j.rootLogger=DEBUG, console, RollingAppender
log4j.appender.RollingAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingAppender.File=c:/temp/log/error_som.log
log4j.appender.RollingAppender.DatePattern='.'yyyy-ww
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingAppender.layout.ConversionPattern= [%d{ISO8601}] %5p%6.6r[%t]%x(%F:%L) - %m%n
And finally, what I get in the log file is just:
[2015-06-09 14:17:18,197] INFO 6042 (MainBusiness.java:122) - App started
I have checked by debugging that sessionInit() is called, and the LOGGER.info() call inside it is also performed. However, the log4j Appender only received the message corresponding to the servletInitialized() function.
Any idea on what can be happening?
Thanks, Cris