Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Java error log 
 

Java error log is a error that arises due to internal error. A error logger is simple an object that is used to show an error log message for a specifice system and component used in an application.

 

Java error log

                         

Java error log is a error that arises due to internal error. A error logger is simple an object that is used to show an error log message for a specifice system and component used in an application.

In this Tutorial we want to describe you a code that show a java error log, for this we have  a Class name'javaerrorlog' .Inside the class name we have a private static  variable logger that returns you a logger name according to  name of the parameter passed in it by calling a method name get Logger(). Inside the main static method ( ) . The class file handler is inherited from java.util.logging.The function of file handler is to either write in the specified file used in your programming. The file handler write to a specified file i.e. log.txt and store in a object of class File Handler name 'handler'.

 

 

Now understand list of method used in code-

add Handler This is used to add a handler in order to receive  logging message.
set Level This method returns you or set the level for a  globally registered method. In brief you can say this  is used to set the log level message specify the message logged by the specified user.
info

This method return you an info  message to you. The code consists of try-catch block to check the exception arises in code. for every subsequent try block there is a catch block that consists of a method name.

log  This method return you log a log record.

code to understand java log error


import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class javaerrorlog {
private static Logger l = Logger.getLogger("");
     
    public static void main(String args[]) throws Exception
        FileHandler handler = new FileHandler("log.txt");
               l.addHandler(handler);
       
        l.setLevel(Level.ALL);
       
        l.info("Error logs");
        try {
          
        catch (Error ex) {
            l.log(Level.INFO, "", ex);
        }
        l.fine("");
    }
}

Output
compile-single:
run-single:
22 Oct, 2008 6:05:40 PM java.util.logging.LogManager$RootLogger log
INFO: Error logs
BUILD SUCCESSFUL (total time: second)

Download code

                         

» View all related tutorials
Related Tags: c class ant help property get tutorial name ria this for to e des pe in as sta m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.