blob: f7f71c876363061f2b3a18154ebffef6155d81d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/**
*
* Copyright (C) 2013 TomTom International B.V.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
package org.genivi.trafficinfo.demo.logging;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
public class EclipseConsoleFormatterDemo {
private final static Logger LOGGER = Logger.getLogger(EclipseConsoleFormatterDemo.class.getName());
public static void main(String args[]) {
EclipseConsoleFormatterDemo logTest = new EclipseConsoleFormatterDemo();
logTest.logSetup();
logTest.writeOutput();
}
private void logSetup() {
// Create Logger
Logger logger = Logger.getLogger("");
logger.setLevel(Level.INFO);
Handler consoleHandler = null;
for (Handler handler: logger.getHandlers()) {
if (handler.getClass().getName().equals("java.util.logging.ConsoleHandler")) {
consoleHandler = handler;
break;
}
}
consoleHandler.setFormatter(new EclipseConsoleFormatter());
}
private void writeOutput() {
LOGGER.info("Where am I?");
}
}
|