public class Logging extends Object
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);
}
Log4jLogging
,
DefaultLogging
,
LogFormatter
Modifier and Type | Field and Description |
---|---|
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 |
Modifier | Constructor and Description |
---|---|
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) |
Modifier and Type | Method and Description |
---|---|
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) |
public static final String LOG_FILE_PROPERTY
public static final String ERR_FILE_PROPERTY
public static final String LOG_MAX_FILE_SIZE_PROPERTY
public static final String ERR_MAX_FILE_SIZE_PROPERTY
public static final String DEFAULT_MAX_FILE_SIZE
protected Logging()
decorateLogMessage(String)
method.protected Logging(String name)
public static void configureLogFile(String log_file)
LOG_FILE_PROPERTY
system property.public final void configureDebugEnabled(boolean default_debug_enabled)
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.public final boolean debugEnabled()
public final void debug(String message)
public final void info(String message)
public final void warn(String message)
public final void error(String message)
public final RuntimeException log(RuntimeException e)
Copyright © 2014 Devexperts. All Rights Reserved.