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); }
Note that some configuration methods (configureLogFile(String)
,
configureDebugEnabled(boolean)
, and properties like LOG_FILE_PROPERTY
) may not work
on some "bridge" implementations (i.e. SLF4J and others).
Log4j2Logging
,
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_CLASS_NAME |
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 defaultDebugEnabled)
Changes default
debugEnabled() behaviour for this logging instance. |
static void |
configureLogFile(String logFile)
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) |
String |
getName()
Returns category name of this logging.
|
void |
info(String message) |
void |
info(String message,
Throwable t) |
RuntimeException |
log(RuntimeException e) |
void |
trace(String message) |
void |
warn(String message) |
void |
warn(String message,
Throwable t) |
public static final String LOG_CLASS_NAME
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 logFile)
LOG_FILE_PROPERTY
system property.public final String getName()
public final void configureDebugEnabled(boolean defaultDebugEnabled)
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 trace(String message)
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 © 2002–2025 Devexperts LLC. All rights reserved.