Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view java log files in Eclipse

I am running some JUnit tests in Eclipse, and my code is generating an XML log file using the java logging APIs. (java.util.logging). Is there an easy way to view this XML log output in Eclipse, other than reading the raw XML? Specifically I want to be able to easily see what threads different log messages have come from.

like image 626
Simon Avatar asked Jun 19 '09 00:06

Simon


People also ask

Where do Eclipse logs go?

When using eclipse the main place to look for logging is in the workspace log file located at <workspace>/. metadata/. log .

How do I get all logs in Eclipse?

Go-to Eclipse Menu: Run -> Run Configuration. Go-to Common tab. Under Standard Input and Output: Select Output file checkbox, enter log file name and path where you want logs to be redirected. Apply changes and run your application.

How do I view file logs?

Locating Log Files. Most log files are located in the /var/log/ directory. Some applications such as httpd and samba have a directory within /var/log/ for their log files. You may notice multiple files in the log file directory with numbers after them.


1 Answers

I've been using the SLF4J logging API coupled with the Logback logging implementation. SLF4J can be configured to map log messages in the java.util.logging, log4j, jakarta commons logging, and SLF4j APIs into a common intermediate form. On the other side, the messages can be generated via java.util.logging, log4j, or Logback. It's a flexible approach that works well, especially when you have components that use different logging APIs.

One nice thing about Logback is that you can configure it to send a copy of the log messages to a an Eclipse plug-in. The plug-in and lets you view and filter the log file in a variety of ways. Messages contain the thread that generated them, so it sounds like something you should check out.

like image 199
Jim Ferrans Avatar answered Sep 22 '22 04:09

Jim Ferrans