Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
how to cofigure and use logging with vaadin + tomcat 6
hello vaadiners
I am using:
- Tomcat 6
- vaadin 6.4 without any additional framework ( eg: spring)
Maybe its a trivial question but I haven't done it yet so I would like to do how to do the following:
I would like to log my application's errors and exceptions into separate log file ( forexample mywebapp.log) instead of the standard catalina.out ( what tomcat uses by default for every webapp)
It is not clear for me:
- how to configure tomcat to use a separate logfile for my webapp?
- and what to write in my webapp to log exceptions/errors/whatever I want to that log file?
I would really appreciate your help as I am stucked after hours of googling :(
Hi Peter,
Essentially, you should use a logging "framework", and configure the logging framework to write to a file.
e.g. http://www.slf4j.org/, http://logback.qos.ch/
You would have to explicitly catch and exceptions to the log; but really, that's not such a bad thing...
See http://wiki.apache.org/tomcat/FAQ/Logging
How should I log in my own webapps?
While you can use System.out and System.err to log, we strongly recommend using a toolkit like Log4J or JDK 1.4's java.util.logging package. With these toolkits, you have significantly more functionality. For example, sending emails, logging to a database, controlling at runtime the logging level of different classes, inspecting the logs with a graphical viewer, etc.We also recommend that you separate your logging from Tomcat's internal logging. That means you should bundle your logging toolkit with your webapp. If you are using Log4J, for example, place the Log4J jar in the WEB-INF/lib directory of your webapp and the Log4J configuration file in the WEB-INF/classes directory of your webapp. This way different web applications can have different logging configurations and you don't need to worry about them interfering with each other.
Cheers,
Charles
There's a new section in the Book on logging. It will be in the 6.5 book, which will be released next week, so it's not very visible in the website, but you can view it here. See also #5775.
There's also a basic on-line demo.
In which folder exactly should the "logging.properties" file be put? I read in the doc to use the "default vaadin package" but that sadly didn't help me... WebContent, WEB-INF, ..?
It actually says "the default package of your Vaadin application". This means directly under the "src" or "source" directory in an Eclipse environment, or under the "src/main/java" or "src/main/resources" in a Maven set-up.
Normally the compile or build process will copy the file directly under WEB-INF/classes
can you tell me what to write into the logging.properties file if I want a context-path.log (for example my-vaadin-project.log) file in the same directory where catalina.out is located?
where can I found more information about the logging.properties file and its content?
In regards to the Logger class referenced in 11.15 Logging, what is the fully qualified package name of the reccomended Logger class?
i.e. java.util.logging.Logger or what?
private static final Logger logger =
Logger.getLogger(MyClass.class.getName());
That looks to me like the Java SE one, java.util.logging.Logger.
However, I think it's a bug in the book to suggest that users declare it as static. While that's fine in a non-container managed application (e.g. a desktop app), it's a Bad Thing in a system where a container manages the lifecycle of your application. It will leak class loaders whenever the app is undeployed.
I'll start a new thread on it in the misc discussion area, but I need to find some references probably for this very obscure issue.
Cheers,
Bobby