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 :frowning:

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

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

thank you very much for the quick response!

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