The log4j level class has the following constructor:
protected Level(int level, String levelStr,int syslogEquivalent)
My question is: when is String levelStr parameter used?
I defined my own custom application, and in it I defined a custom Level as follows:
public static class CustomLevel extends Level { private static final long serialVersionUID = 1L; public static final Level ALERT = new CustomLevel(FATAL_INT, "ALERT", 2); protected CustomLevel(int level, String levelStr, int syslogEquivalent) { super(level, levelStr, syslogEquivalent); } }
In my application, in the append method append I do:
Level newLevel = CustomLevel.ALERT; etc. LoggingEvent newLoggingEvent = new LoggingEvent( event.getFQNOfLoggerClass(), event.getLogger(), event.getTimeStamp(), newLevel, event.getMessage(), event.getThreadName(), event.getThrowableInformation(), event.getNDC(), event.getLocationInformation(), event.getProperties()); super.append(newLoggingEvent);
In the log output, when I do custom_Logger.fatal(msg); , I can see my message, but the level is FATAL .
main FATAL logging.customlog - Send an Error Message to log
I thought it would be ALERT as defined at my user level (i.e. main ALERT ).
So what am I doing something wrong? Should I see ALERT in the output log?
If not, when is leveStr used?