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

Getting the Log Level of a Logger

This section helps you to learn about the getting log level of a logger through the java program and illustrates how to get it.

Getting the Log Level of a Logger

                         

This section helps you to learn about the getting log level of a logger through the java program and illustrates how to get it. The Logger provides various types of levels of a logger like: INFO, WARNING, SEVERE and FINEST etc.

In this section, an example is provided for the best illustration of the topic. In the following program, a object of the LogRecord class is created with the log level and the log message for the specific log record. And the last thing is getting log level and display it in the console.

Description of code:

LogRecord rec1 = new  LogRecord(Level.WARNING, "Do something here!"):
Above code creates an object of the LogRecord class with specifying log level and the message for the logger.

LogRecord.getLevel():
This method gives you the level of the log record and for the specific object of the LogRecord class.

Here is the code of program:

import java.util.logging.*;

public class GetLogLevel{
  public static void main(String[] args) {
    LogRecord rec1 = new LogRecord(Level.WARNING,"Do something here!");
    System.out.println(rec1.getLevel());
    LogRecord rec2 = new LogRecord(Level.INFO,"Do something here!");
    System.out.println(rec2.getLevel());
    LogRecord rec3 = new LogRecord(Level.SEVERE,"Do something here!");
    System.out.println(rec3.getLevel());
  }
}

Download this example.

Output:

C:\java\logging>java GetLogLevel
WARNING
INFO
SEVERE

                         

» View all related tutorials
Related Tags: c reference methods references method user system using id package node create check if preferences for call exists to automatic

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 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
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

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

Copyright © 2008. All rights reserved.