mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +00:00
Updated LogManager
This commit is contained in:
parent
6fc583d6f0
commit
7cbfb822b8
@ -19,9 +19,30 @@ public class LogManager {
|
||||
public static void initialize() {
|
||||
LOGGER.setUseParentHandlers(false);
|
||||
|
||||
Handler handler = new ConsoleHandler();
|
||||
/*
|
||||
* Having warning/error directed to stderr
|
||||
*/
|
||||
Handler errHandler = new ConsoleHandler();
|
||||
errHandler.setFormatter(new GenericFormatter());
|
||||
errHandler.setLevel(Level.WARNING);
|
||||
|
||||
/*
|
||||
* Only have info and below directed to stdout
|
||||
*/
|
||||
Handler handler = new StreamHandler(System.out, new GenericFormatter()) {
|
||||
@Override
|
||||
public synchronized void publish(LogRecord record) {
|
||||
super.publish(record);
|
||||
flush();
|
||||
}
|
||||
};
|
||||
handler.setFilter(new Filter() {
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
return record.getLevel().intValue() <= Level.INFO.intValue();
|
||||
}
|
||||
});
|
||||
handler.setLevel(Level.ALL);
|
||||
handler.setFormatter(new GenericFormatter());
|
||||
|
||||
try {
|
||||
Handler fileHandler = new FileHandler("mar.log");
|
||||
@ -29,6 +50,7 @@ public class LogManager {
|
||||
fileHandler.setFormatter(new GenericFormatter());
|
||||
|
||||
LOGGER.addHandler(handler);
|
||||
LOGGER.addHandler(errHandler);
|
||||
LOGGER.addHandler(fileHandler);
|
||||
LOGGER.setLevel(Level.ALL);
|
||||
|
||||
@ -36,6 +58,5 @@ public class LogManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user