Logger Info() Example

Log an INFO message.


Loggerclass Info() method example. This example shows you how to use Info() method.This method Log an INFO message.

Here is the code:-
/* 
 * @Program that Log an INFO message.
 * Info.java 
 * Author:-RoseIndia Team
 * Date:-1-July-2008
 */

import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Logger;

public class Info {

    public static void main(String args[]) {
        //created logger
        Logger logger = Logger.getLogger("net.log");
        //declaring handler
        Handler handler = null;
        try {
            //creating a handler
            handler = new FileHandler("Rose.log");
        catch (IOException e) {
            System.out.println("File not created");
            handler = new ConsoleHandler();
        }
        //Adding a log Handler to receive logging messages.
        logger.addHandler(handler);
        //Log an INFO message.
        logger.info("INFO Message");
    }
}

Output of the program:-
 2 Jul, 2008 1:45:23 PM Info main
INFO: INFO Message

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US