Logger Log4() Example
Log a message, with associated Throwable information.
Loggerclass Log4() method example. This example shows you how to use Log4() method.This method Log a message, with associated Throwable information.
Here is the code:-
/*
* @Program that Log a message, with associated Throwable information.
* Log4.java
* Author:-RoseIndia Team
* Date:-1-July-2008
*/
import java.util.logging.Filter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.lang.Throwable;
public class Log4 {
public static void main(String[] args) {
Logger logger = Logger.getLogger("girish.log");
Throwable throwable=new Throwable("File not found");
//Log a message, with associated Throwable information.
logger.log(Level.WARNING,"Roseindia.net",throwable);
}
} |
Output of the program:-
1 Jul, 2008 4:41:24 PM Log4 main
WARNING: Roseindia.net
java.lang.Throwable: File not found |
|