Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 1999-2005 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 // Contributors:  Kitching Simon <Simon.Kitching@orange.ch>
 //                Nicholas Wolff
 
 package org.apache.log4j;
Defines the minimum set of levels recognized by the system, that is OFF, FATAL, ERROR, WARN, INFODEBUG and ALL.

The Level class may be subclassed to define a larger level set.

Author(s):
Ceki Gülcü
 
 public class Level extends Priority implements Serializable {

   
TRACE level integer value.

Since:
1.2.12
 
   public static final int TRACE_INT = 5000;

  
The OFF has the highest possible rank and is intended to turn off logging.
 
   final static public Level OFF = new Level("OFF", 0);

  
The FATAL level designates very severe error events that will presumably lead the application to abort.
 
   final static public Level FATAL = new Level("FATAL", 0);

  
The ERROR level designates error events that might still allow the application to continue running.
 
   final static public Level ERROR = new Level("ERROR", 3);

  
The WARN level designates potentially harmful situations.
 
   final static public Level WARN  = new Level("WARN",  4);

  
The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
 
   final static public Level INFO  = new Level("INFO",  6);

  
The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
 
   final static public Level DEBUG = new Level("DEBUG", 7);

  
The TRACE Level designates finer-grained informational events than the DEBUG

Since:
1.2.12
 
   public static final Level TRACE = new Level("TRACE", 7);


  
The ALL has the lowest possible rank and is intended to turn on all logging.
 
   final static public Level ALL = new Level("ALL", 7);

  
Serialization version id.
 
   static final long serialVersionUID = 3491141966387921974L;

  
Instantiate a Level object.
  protected
  Level(int levelString levelStrint syslogEquivalent) {
    super(levellevelStrsyslogEquivalent);
  }


  
Convert the string passed as argument to a level. If the conversion fails, then this method returns DEBUG.
  public
  static
  Level toLevel(String sArg) {
    return (LeveltoLevel(sArg.);
  }

  
Convert an integer passed as argument to a level. If the conversion fails, then this method returns DEBUG.
  public
  static
  Level toLevel(int val) {
    return (LeveltoLevel(val.);
  }

  
Convert an integer passed as argument to a level. If the conversion fails, then this method returns the specified default.
  public
  static
  Level toLevel(int valLevel defaultLevel) {
    switch(val) {
    case return ;
    case return .;
    case return .;
    case return .;
    case return .;
    case return .;
    case return ;
    case return .;
    defaultreturn defaultLevel;
    }
  }

  
Convert the string passed as argument to a level. If the conversion fails, then this method returns the value of defaultLevel.
  public
  static
  Level toLevel(String sArgLevel defaultLevel) {                  
    if(sArg == null)
       return defaultLevel;
    
    String s = sArg.toUpperCase();
    if(s.equals("ALL")) return .
    if(s.equals("DEBUG")) return .
    if(s.equals("INFO"))  return .;
    if(s.equals("WARN"))  return .;  
    if(s.equals("ERROR")) return .;
    if(s.equals("FATAL")) return .;
    if(s.equals("OFF")) return .;
    if(s.equals("TRACE")) return .;
    return defaultLevel;
  }

    
Custom deserialization of Level.

Parameters:
s serialization stream.
Throws:
java.io.IOException if IO exception.
java.lang.ClassNotFoundException if class not found.
    private void readObject(final ObjectInputStream sthrows IOExceptionClassNotFoundException {
      s.defaultReadObject();
       = s.readInt();
       = s.readInt();
       = s.readUTF();
      if ( == null) {
           = "";
      }
    }

    
Serialize level.

Parameters:
s serialization stream.
Throws:
java.io.IOException if exception during serialization.
    private void writeObject(final ObjectOutputStream sthrows IOException {
        s.defaultWriteObject();
        s.writeInt();
        s.writeInt();
        s.writeUTF();
    }

    
Resolved deserialized level to one of the stock instances. May be overriden in classes derived from Level.

Returns:
resolved object.
Throws:
java.io.ObjectStreamException if exception during resolution.
    private Object readResolve() throws ObjectStreamException {
        //
        //  if the deserizalized object is exactly an instance of Level
        //
        if (getClass() == Level.class) {
            return toLevel();
        }
        //
        //   extension of Level can't substitute stock item
        //
        return this;
    }
New to GrepCode? Check out our FAQ X