You can do logging in Vaadin application using the standard java.util.logging facilities. Configuring logging is as easy as putting a file named logging.properties in the default package of your Vaadin application. This file is read by the Logger class when a new instance of it is initialize.

Piping output from java.util.logging to Log4j is easy with SLF4J (http://slf4j.org/). 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 Application class at the very top:

  static {
    SLF4JBridgeHandler.install();
  }

This will make sure that the bridge handler is installed and working before Vaadin starts to process any logging calls.

Please note!

This can seriously impact on the cost of disabled logging statements (60-fold increase) and a measurable impact on enabled log statements (20% overall increase). However, Vaadin doesn't log very much, so the effect on performance will be negligible.