in the following code example the handler does not repect the call to setLevel.
Logger globalLogger = Logger.getLogger("");
Handler handler = new LogMailHandler();
handler.setLevel(Level.SEVERE);
globalLogger.addHandler(handler);
Logger local = Logger.getLogger(LogMailHandlerTest.class.getName());
local.severe("Test message severe...");
local.info("Test message info...");
LogMailHandler is defined as follows:
public class LogMailHandler extends Handler {
@Override
public void publish(LogRecord pRecord) {
System.out.println("Error registered..." + pRecord.getLevel().getName());
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
}
The output is:
Jan 19, 2015 5:20:33 PM com.idmedia.fts.exchange.helper.LogMailHandlerTest main
SEVERE: Test message severe...
Error registered...SEVERE
Jan 19, 2015 5:20:33 PM com.idmedia.fts.exchange.helper.LogMailHandlerTest main
INFO: Test message info...
Error registered...INFO
In my opinion the "Error registered...INFO" should not be there since the level of the handler was set to SEVERE.
Any suggestions?