1

How do i enable and use logging and tracing in my java program?

2
  • What do you mean by logging and tracing? You mean jvm logging? Commented Aug 27, 2010 at 9:22
  • I want to redirect my console output to other handlers and also would like to store such a log in any file Commented Aug 27, 2010 at 9:28

7 Answers 7

2

If you want to start using logging in java, I advise you to start with the log4j FAQ and its manual which is a good introduction.

Sign up to request clarification or add additional context in comments.

Comments

2

Without downloading third party libraries you could use Java Logging API - Tutorial

1 Comment

This would be my recommendation. I appreciate that people often recommend Log4J, perhaps with good reason, but I've generally found JDK 1.4 logging suitable for my needs without, as you say, the need for extra jars.
1

There are a number of well-known logging APIs for Java. The most well-known is Log4J. Since Java 1.4, there's also a logging API in the standard library, in the package java.util.logging.

There is also SLF4J, which is not a logging library itself, but an interface layer which you can put between your program and a logging library such as Log4J or java.util.logging. So, you use the SLF4J API, and SLF4J passes the log messages on to whatever logging library you configure. The advantage of this is that users of your program can plug in a different logging library if they want.

1 Comment

The main advantage of SLF4J is that when you start using different components, they often end up using different logging frameworks. Hopefully slf4j will alleviate this.
1

If you want to trace the execution of your Java code without having to add logging statements you can use a tool called InTrace.

NOTE: InTrace is a free and open source tool which I have written.

Comments

0

You may use log4j, just then I suggest you to take a look at this tutorial. I think it's a quite good and straightforward to start with.

Comments

0

If you want you can use a logger package like Commons Logging or Log4J or any other.

For tracing, you can use Jconsole, a tool that comes packaged with JDK. I use this in my application for monitoring jobs, memory utilization etc.

Comments

0

Jackplay is designed to assist you ing tracing/logging on your application methods without any code change or redeployment.

It also allows you to redefine a method body LIVE in JVM.

It presents easy to use Web based UI as control panel.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.