Hi toantp
To add your own level try this:
1. use the following code to create an own level.
2. set the Priority value in the log4j.xml to your level name (here: "TEST")
3. Use your new level: logger.log(TestLevel.Test, "Test output");
4. If the entry does not show up in the log, alter the DEBUGINT between -100 and + 100
import org.apache.log4j.Level;
public class TestLevel extends Level {
public static final int TEST_INT = DEBUG_INT + 1;
public static final Level TEST = new MyTraceLevel(TEST_INT, TestLevel(TEST_INT, "TEST", 7);
protected TestLevel(int arg0, String arg1, int arg2) {
super(arg0, arg1, arg2);
}
public static Level toLevel(String sArg) {
if (sArg != null && sArg.toUpperCase().equals("TEST")) {
return TEST;
}
return (Level) toLevel(sArg, Level.DEBUG);
}
public static Level toLevel(int val) {
if (val == TEST_INT) {
return TEST;
}
return (Level) toLevel(val, Level.DEBUG);
}
public static Level toLevel(int val, Level defaultLevel) {
if (val == TEST_INT) {
return TEST;
}
return Level.toLevel(val,defaultLevel);
}
public static Level toLevel(String sArg, Level defaultLevel) {
if(sArg != null && sArg.toUpperCase().equals("TEST")) {
return TEST;
}
return Level.toLevel(sArg,defaultLevel);
}
}