Yo Momma
Yo Momma

Reputation: 8781

How do I view the Java Log?

I have a jsp project where I using the java.util.logging.Logger class to log information. At the moment my code is logging exceptions using this class, however, i would like to view the data written this log. How do I do that?

Upvotes: 4

Views: 22285

Answers (5)

kostja
kostja

Reputation: 61578

You will need to configure the logging output to write into a file (or the console). You can then tail the file to keep up-to-date.

Upvotes: 3

yudis
yudis

Reputation: 49

If you are using Java Logging API then you can use http://sourceforge.net/projects/jlogviewer/ - it accepts .log or .xml

Upvotes: 0

Stephen C
Stephen C

Reputation: 719576

As the anonymous horse said, there are lots of tools for doing this.

But if you want to do it within a Java application, then there are two approaches:

  • You could use something like the Apache Commons Tailer class to read stuff written to the end of the log file.

  • You could create your subclass of java.util.logging.Handler to process the log events before they reach the log file.

Upvotes: 0

LoSciamano
LoSciamano

Reputation: 1119

When you initialize your Logger class you have to add Handler to enable writing this somewhere. For Example if you want to write this to a file use the FileHandler

logger.addHandler(new FileHandler("mylog.log");

Refer to the Handler documentation for more infos: http://download.oracle.com/javase/1.4.2/docs/api/java/util/logging/Handler.html

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160311

It depends how your logging is set up.

In general, it will either be in your server log (for example, for Tomcat, they're in the Tomcat home directory under the logs directory), or in a file that's been configured for the app.

Upvotes: 6

Related Questions