com.devexperts.logging
Class Logging

java.lang.Object
  extended by com.devexperts.logging.Logging

public class Logging
extends Object

Main logging class. It supports use of both log4j and java.util.logging logging facilities.

First it tries to use log4j logging. If this attempt fails, it uses java.util.logging logging, so you'll always have some logging running.

Usage pattern:
public class SomeClass {
private static final Logging log = Logging.getLogging(SomeClass.class);
}

See Also:
Log4jLogging, DefaultLogging, LogFormatter

Field Summary
static String DEFAULT_MAX_FILE_SIZE
           
static String ERR_FILE_PROPERTY
           
static String ERR_MAX_FILE_SIZE_PROPERTY
           
static String LOG_FILE_PROPERTY
           
static String LOG_MAX_FILE_SIZE_PROPERTY
           
 
Constructor Summary
protected Logging()
          This constructor is designed for abstract framework classes like BeanBase or DAOBase that extend Logging to decorate messages by overriding decorateLogMessage(String) method.
protected Logging(String name)
           
 
Method Summary
 void configureDebugEnabled(boolean default_debug_enabled)
          Changes default debugEnabled() behaviour for this logging instance.
static void configureLogFile(String log_file)
          Programmatically reconfigures logging to a specified file.
 void debug(String message)
           
 void debug(String message, Throwable t)
           
 boolean debugEnabled()
           
protected  String decorateLogMessage(String msg)
          Decorates log message (reformatting, auditing, etc).
 void error(String message)
           
 void error(String message, Throwable t)
           
static Logging getLogging(Class<?> clazz)
           
static Logging getLogging(String name)
           
 void info(String message)
           
 void info(String message, Throwable t)
           
 RuntimeException log(RuntimeException e)
           
 void warn(String message)
           
 void warn(String message, Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE_PROPERTY

public static final String LOG_FILE_PROPERTY
See Also:
Constant Field Values

ERR_FILE_PROPERTY

public static final String ERR_FILE_PROPERTY
See Also:
Constant Field Values

LOG_MAX_FILE_SIZE_PROPERTY

public static final String LOG_MAX_FILE_SIZE_PROPERTY
See Also:
Constant Field Values

ERR_MAX_FILE_SIZE_PROPERTY

public static final String ERR_MAX_FILE_SIZE_PROPERTY
See Also:
Constant Field Values

DEFAULT_MAX_FILE_SIZE

public static final String DEFAULT_MAX_FILE_SIZE
See Also:
Constant Field Values
Constructor Detail

Logging

protected Logging()
This constructor is designed for abstract framework classes like BeanBase or DAOBase that extend Logging to decorate messages by overriding decorateLogMessage(String) method.


Logging

protected Logging(String name)
Method Detail

getLogging

public static Logging getLogging(Class<?> clazz)

getLogging

public static Logging getLogging(String name)

configureLogFile

public static void configureLogFile(String log_file)
Programmatically reconfigures logging to a specified file. This method overrides the value of LOG_FILE_PROPERTY system property.


configureDebugEnabled

public final void configureDebugEnabled(boolean default_debug_enabled)
Changes default debugEnabled() behaviour for this logging instance. Use this method to turn off debugging information for classes that do not need to print their debugging information in production environment.


debugEnabled

public final boolean debugEnabled()

debug

public final void debug(String message)

debug

public final void debug(String message,
                        Throwable t)

info

public final void info(String message)

info

public final void info(String message,
                       Throwable t)

warn

public final void warn(String message)

warn

public final void warn(String message,
                       Throwable t)

error

public final void error(String message)

error

public final void error(String message,
                        Throwable t)

log

public final RuntimeException log(RuntimeException e)

decorateLogMessage

protected String decorateLogMessage(String msg)
Decorates log message (reformatting, auditing, etc). This method is invoked one time for each logging event.



Copyright © 2013 Devexperts. All Rights Reserved.