Logging
For logging Vaadin applications deployed in Apache Tomcat, you do not need to do anything special to log to the same place as Tomcat itself. If you need to write the Vaadin application related messages elsewhere, just add a custom logging.properties file to the default package of your Vaadin application.
If you would like to pipe the log messages through another logging solution, see Piping to Log4j using SLF4J below.
Liferay mutes logging through java.util.logging by default. In order to enable logging, you need to add a logging.properties file of your own to the default package of your Vaadin application. This file should define at least one destination where to save the log messages.
Piping output from java.util.logging to Log4j is easy with SLF4J ( ). The basic way to go about this is to add the SLF4J JAR file as well as the jul-to-slf4j.jar file, which implements the bridge from java.util.logging, to SLF4J. You will also need to add a third logging implementation JAR file, that is, slf4j-log4j12-x.x.x.jar, to log the actual messages using Log4j. For more info on this, please visit the SLF4J site.
In order to get the java.util.logging to SLF4J bridge installed, you need to add the following snippet of code to your UI class at the very top://TODO: Sure it’s UI class and not the servlet?
Java
You can do logging with a simple pattern where you register a static logger instance in each class that needs logging, and use this logger wherever logging is needed in the class. For example:
Java
private final static Logger logger =
Logger.getLogger(MyClass.class.getName());
// do something that might fail
} catch (Exception e) {
}
}