Hi ,
How do i enable and use logging and tracing in my java program?
Thanks, magggi
Hi ,
How do i enable and use logging and tracing in my java program?
Thanks, magggi
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.
Without downloading third party libraries you could use Java Logging API - Tutorial
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.
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.