com.metsci.glimpse.util.logging
Class LoggerUtils

java.lang.Object
  extended by com.metsci.glimpse.util.logging.LoggerUtils

public class LoggerUtils
extends java.lang.Object

Author:
moskowitz

Nested Class Summary
static class LoggerUtils.LoggingOutputStream
          An OutputStream that writes contents to a Logger upon each call to flush() Original URL: https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and Author gives permission for free use in blog comments section.
static class LoggerUtils.StdOutErrLevel
          Class defining 2 new Logging levels, one for STDOUT, one for STDERR, used when multiplexing STDOUT and STDERR into the same rolling log file via the Java Logging APIs.

From: http://blogs.sun.com/nickstephen/entry/java_redirecting_system_out_and
 
Constructor Summary
LoggerUtils()
           
 
Method Summary
static void addTerseFileLogger(java.util.logging.Level level, java.lang.String filename)
          In cases where a logging.properties file is too cumbersome, sets terse formatter for file handler.
 void dumpAncestry(java.util.logging.Logger logger)
          Prints own and parents' log levels to standard out (for debugging).
static java.util.logging.Level getLevelRecursive(java.util.logging.Logger logger)
          Traverses parents to find effective log level.
static void initializeLogging()
          Initialize Java logging to use "logging.properties" as the configuration file and re-read the logging configuration from this file.
static void initializeLogging(java.lang.String configurationFilename)
          Initialize Java logging to use given configuration file and re-read the logging configuration from this file.
static void log(java.util.logging.Logger logger, java.util.logging.Level level, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void log(java.util.logging.Logger logger, java.util.logging.Level level, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logConfig(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logConfig(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFine(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFine(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFiner(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFiner(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFinest(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logFinest(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logInfo(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logInfo(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logSevere(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logSevere(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logWarning(java.util.logging.Logger logger, java.lang.String format, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void logWarning(java.util.logging.Logger logger, java.lang.String format, java.lang.Throwable thrown, java.lang.Object... args)
          Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.
static void sendStderrToLog()
           
static void sendStdoutToLog()
           
static void setLoggerLevel(java.util.logging.Level level)
           
static void setTerseConsoleLogger(java.util.logging.Level level)
          In cases where a logging.properties file is too cumbersome, sets terse formatter for console handler.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerUtils

public LoggerUtils()
Method Detail

getLevelRecursive

public static java.util.logging.Level getLevelRecursive(java.util.logging.Logger logger)
Traverses parents to find effective log level.


dumpAncestry

public void dumpAncestry(java.util.logging.Logger logger)
Prints own and parents' log levels to standard out (for debugging).


initializeLogging

public static void initializeLogging()
Initialize Java logging to use "logging.properties" as the configuration file and re-read the logging configuration from this file.

Note: Similar to setting -Djava.util.logging.config.file=logging.properties on java command line.


initializeLogging

public static void initializeLogging(java.lang.String configurationFilename)
Initialize Java logging to use given configuration file and re-read the logging configuration from this file.

Note: Similar to setting -Djava.util.logging.config.file=configurationFilename on java command line.


setTerseConsoleLogger

public static final void setTerseConsoleLogger(java.util.logging.Level level)
In cases where a logging.properties file is too cumbersome, sets terse formatter for console handler.

Parameters:
level - maximum logging level; set on root logger

addTerseFileLogger

public static final void addTerseFileLogger(java.util.logging.Level level,
                                            java.lang.String filename)
                                     throws java.lang.SecurityException,
                                            java.io.IOException
In cases where a logging.properties file is too cumbersome, sets terse formatter for file handler.

Parameters:
level - maximum logging level; set on root logger
Throws:
java.io.IOException
java.lang.SecurityException

setLoggerLevel

public static final void setLoggerLevel(java.util.logging.Level level)

sendStdoutToLog

public static void sendStdoutToLog()

sendStderrToLog

public static void sendStderrToLog()

log

public static void log(java.util.logging.Logger logger,
                       java.util.logging.Level level,
                       java.lang.String format,
                       java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFinest

public static void logFinest(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFiner

public static void logFiner(java.util.logging.Logger logger,
                            java.lang.String format,
                            java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFine

public static void logFine(java.util.logging.Logger logger,
                           java.lang.String format,
                           java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logConfig

public static void logConfig(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logInfo

public static void logInfo(java.util.logging.Logger logger,
                           java.lang.String format,
                           java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logWarning

public static void logWarning(java.util.logging.Logger logger,
                              java.lang.String format,
                              java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logSevere

public static void logSevere(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


log

public static void log(java.util.logging.Logger logger,
                       java.util.logging.Level level,
                       java.lang.String format,
                       java.lang.Throwable thrown,
                       java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFinest

public static void logFinest(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Throwable thrown,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFiner

public static void logFiner(java.util.logging.Logger logger,
                            java.lang.String format,
                            java.lang.Throwable thrown,
                            java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logFine

public static void logFine(java.util.logging.Logger logger,
                           java.lang.String format,
                           java.lang.Throwable thrown,
                           java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logConfig

public static void logConfig(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Throwable thrown,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logInfo

public static void logInfo(java.util.logging.Logger logger,
                           java.lang.String format,
                           java.lang.Throwable thrown,
                           java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logWarning

public static void logWarning(java.util.logging.Logger logger,
                              java.lang.String format,
                              java.lang.Throwable thrown,
                              java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.


logSevere

public static void logSevere(java.util.logging.Logger logger,
                             java.lang.String format,
                             java.lang.Throwable thrown,
                             java.lang.Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting if unneeded.



Copyright © 2012 Metron, Inc.. All Rights Reserved.