为不用和其他级别冲突,有时候需要自己定义级别,查看源码,代码如下:
package org.apache.log4j;
/**
<font color="#AA4444">Refrain from using this class directly, use
the {@link Level} class instead</font>.
@author Ceki Gülcü */
public class Priority {
transient int level;
transient String levelStr;
transient int syslogEquivalent;
public final static int OFF_INT = Integer.MAX_VALUE;
public final static int FATAL_INT = 50000;
public final static int ERROR_INT = 40000;
public final static int WARN_INT = 30000;
public final static int INFO_INT = 20000;
public final static int DEBUG_INT = 10000;
//public final static int FINE_INT = DEBUG_INT;
public final static int ALL_INT = Integer.MIN_VALUE;
通过代码可以出来Level替代了Priority,
那么Level代码如下:
/**
Defines the minimum set of levels recognized by the system, that is
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
<code>WARN</code>, <code>INFO</code, <code>DEBUG</code> and
<code>ALL</code>.
<p>The <code>Level</code> class may be subclassed to define a larger
level set.
@author 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 <code>OFF</code> has the highest possible rank and is
intended to turn off logging. */
final static public Level OFF = new Level(OFF_INT, "OFF", 0);
/**
The <code>FATAL</code> level designates very severe error
events that will presumably lead the application to abort.
*/
final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
/**
The <code>ERROR</code> level designates error events that
might still allow the application to continue running. */
final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
/**
The <code>WARN<