public class LocalLog extends Object implements Log
Log
interface so we can bypass external logging classes if they are not available.
You can set the log level by setting the System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "trace"). Acceptable values are: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. You can also redirect the log to a file by setting the System.setProperty(LocalLog.LOCAL_LOG_FILE_PROPERTY, "log.out"). Otherwise, log output will go to stdout.
It also supports a file simplemagicLocalLog.properties file which contains lines such as:
# regex-pattern = Level log4j\.logger\.com\.j256\.simplemagic.*=TRACE
Modifier and Type | Field and Description |
---|---|
static String |
LOCAL_LOG_FILE_PROPERTY |
static String |
LOCAL_LOG_LEVEL_PROPERTY |
static String |
LOCAL_LOG_PROPERTIES_FILE |
Modifier and Type | Method and Description |
---|---|
boolean |
isLevelEnabled(Log.Level level)
Returns true if the log mode is in trace or higher.
|
void |
log(Log.Level level,
String msg)
Log a trace message.
|
void |
log(Log.Level level,
String msg,
Throwable throwable)
Log a trace message with a throwable.
|
static void |
openLogFile(String logPath)
Reopen the associated static logging stream.
|
public static final String LOCAL_LOG_LEVEL_PROPERTY
public static final String LOCAL_LOG_FILE_PROPERTY
public static final String LOCAL_LOG_PROPERTIES_FILE
public LocalLog(String className)
public static void openLogFile(String logPath)
public boolean isLevelEnabled(Log.Level level)
Log
isLevelEnabled
in interface Log
public void log(Log.Level level, String msg)
Log
This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.