use of java.util.logging.ConsoleHandler in project gatk by broadinstitute.
the class LoggingUtils method setJavaUtilLoggingLevel.
/**
* Set the java.util.logging level since some of our dependencies write messages using it.
*
* Taken with modifications from a post by michel.iamit
* http://stackoverflow.com/users/369060/michel-iamit
* from http://stackoverflow.com/questions/470430/java-util-logging-logger-doesnt-respect-java-util-logging-level
*/
private static void setJavaUtilLoggingLevel(final Log.LogLevel verbosity) {
Logger topLogger = java.util.logging.Logger.getLogger("");
Handler consoleHandler = null;
for (Handler handler : topLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
consoleHandler = handler;
break;
}
}
if (consoleHandler == null) {
consoleHandler = new ConsoleHandler();
topLogger.addHandler(consoleHandler);
}
consoleHandler.setLevel(levelToJavaUtilLevel(verbosity));
}
use of java.util.logging.ConsoleHandler in project ignite by apache.
the class IgniteUtils method addJavaNoOpLogger.
/**
* Adds no-op console handler for root java logger.
*
* @return Removed handlers.
*/
public static Collection<Handler> addJavaNoOpLogger() {
Collection<Handler> savedHnds = new ArrayList<>();
Logger log = Logger.getLogger("");
for (Handler h : log.getHandlers()) {
log.removeHandler(h);
savedHnds.add(h);
}
ConsoleHandler hnd = new ConsoleHandler();
hnd.setLevel(Level.OFF);
log.addHandler(hnd);
return savedHnds;
}
use of java.util.logging.ConsoleHandler in project Payara by payara.
the class EjbClosureCompiler method main.
public static void main(String[] args) {
Handler h = new ConsoleHandler();
h.setLevel(Level.ALL);
// NOI18N
Logger.getLogger("apiscan").addHandler(h);
// NOI18N
Logger.getLogger("apiscan").setLevel(Level.ALL);
int j = 0;
String pcp = "";
String specVer = "";
for (j = 0; j < args.length; ++j) {
if (args[j].equals("-prefixClassPath")) {
// NOI18N
pcp = args[++j];
continue;
} else if (args[j].equals("-specVer")) {
// NOI18N
specVer = args[++j];
continue;
}
}
if (args.length < 5) {
System.out.println(// NOI18N
"Usage: " + EjbClosureCompiler.class.getName() + // NOI18N
" <-prefixClassPath> <prefix classpath> <-specVer> <something like ejb_2.1> <jar file name(s)>");
return;
}
for (int i = 4; i < args.length; ++i) {
try (JarFile jar = new JarFile(args[i])) {
String cp = pcp + File.pathSeparator + ClassPathBuilder.buildClassPathForJar(jar);
// NOI18N
System.out.println("Using CLASSPATH " + cp);
ClassFileLoader cfl = ClassFileLoaderFactory.newInstance(new Object[] { cp });
EjbClosureCompiler ejbClosureCompiler = new EjbClosureCompiler(specVer, cfl);
boolean result = ejbClosureCompiler.buildClosure(jar);
jar.close();
// NOI18N
System.out.println("The closure is [\n");
System.out.println(ejbClosureCompiler);
if (result) {
// NOI18N
System.out.println("Did not find any non-standard APIs ");
} else {
System.out.println(// NOI18N
"Found non-standard APIs for " + args[i]);
}
} catch (IOException e) {
e.printStackTrace();
continue;
}
// NOI18N
System.out.println("\n]");
}
// args[i]
}
use of java.util.logging.ConsoleHandler in project Payara by payara.
the class LoggingAnnotationsTest method initializeLoggingAnnotationsTest.
@BeforeClass
public static void initializeLoggingAnnotationsTest() throws Exception {
File basePath = new File(BASE_PATH);
basePath.mkdirs();
// Add a file handler with UniformLogFormatter
uniformFormatHandler = new FileHandler(ULF_LOG);
uniformFormatHandler.setLevel(Level.FINE);
uniformFormatHandler.setFormatter(new UniformLogFormatter());
// Add a file handler with ODLLogFormatter
odlFormatHandler = new FileHandler(ODL_LOG);
odlFormatHandler.setLevel(Level.FINE);
odlFormatHandler.setFormatter(new ODLLogFormatter());
consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(new UniformLogFormatter());
LOGGER.addHandler(uniformFormatHandler);
LOGGER.addHandler(odlFormatHandler);
Boolean enableConsoleHandler = Boolean.getBoolean(LoggingAnnotationsTest.class.getName() + ".enableConsoleHandler");
if (enableConsoleHandler) {
LOGGER.addHandler(consoleHandler);
}
LOGGER.setUseParentHandlers(false);
LOGGER.setLevel(Level.FINE);
}
Aggregations