public class Logger
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLIENT_LOG_FILE_NAME |
static java.lang.String |
DAILY |
static java.lang.String |
IGNITE_LOG_PATTERN |
static int |
LEVEL_ALL |
static int |
LEVEL_DEBUG |
static int |
LEVEL_ERROR |
static int |
LEVEL_FATAL |
static int |
LEVEL_INFO |
static int |
LEVEL_OFF |
static int |
LEVEL_WARNING |
static java.lang.String |
LOG_PATTERN |
static java.lang.String |
LOG_PATTERN_NO_IP
Deprecated.
|
static java.lang.String |
MONTHLY |
static java.lang.String |
SERVER_LOG_FILE_NAME |
static java.lang.String |
STR_LEVEL_ALL |
static java.lang.String |
STR_LEVEL_DEBUG |
static java.lang.String |
STR_LEVEL_ERROR |
static java.lang.String |
STR_LEVEL_FATAL |
static java.lang.String |
STR_LEVEL_INFO |
static java.lang.String |
STR_LEVEL_OFF |
static java.lang.String |
STR_LEVEL_WARNING |
static java.lang.String |
WEEKLY |
Modifier and Type | Method and Description |
---|---|
void |
all(java.lang.String message) |
void |
all(java.lang.String message,
java.lang.String username) |
void |
all(java.lang.String message,
java.lang.Throwable exception) |
void |
all(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
void |
close()
Closes the logger and remove all appenders.
|
void |
debug(java.lang.String message) |
void |
debug(java.lang.String message,
java.lang.String username) |
void |
debug(java.lang.String message,
java.lang.Throwable exception) |
void |
debug(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
void |
error(java.lang.String message) |
void |
error(java.lang.String message,
java.lang.String username) |
void |
error(java.lang.String message,
java.lang.Throwable exception) |
void |
error(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
void |
fatal(java.lang.String message) |
void |
fatal(java.lang.String message,
java.lang.String username) |
void |
fatal(java.lang.String message,
java.lang.Throwable exception) |
void |
fatal(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
int |
getFileAgeLimit() |
static Logger |
getInstance()
Retrieve an instance of logger by name or creete one if don't exist.
|
int |
getLogLevel() |
java.lang.String |
getLogPath() |
void |
info(java.lang.String message) |
void |
info(java.lang.String message,
java.lang.String username) |
void |
info(java.lang.String message,
java.lang.Throwable exception) |
void |
info(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
void |
init(java.lang.String logPath,
java.lang.String rolloverSchedule,
boolean logToConsole,
java.lang.String logLevel,
int fileAgeLimit,
java.lang.String logFileName)
init a logger "JMap" with parameters.
|
boolean |
isAllEnabled() |
boolean |
isDebugEnabled() |
boolean |
isErrorEnabled() |
boolean |
isFatalEnabled() |
boolean |
isInfoEnabled() |
boolean |
isWarningEnabled() |
boolean |
loadExternalConfig(java.io.File file)
Load an external log4j configuration file.
|
void |
log(int type,
java.lang.String message)
Logs a new message of the specified type.
|
void |
log(int type,
java.lang.String message,
java.lang.String userName)
Logs a new message of the specified type tagged to the specified user.
|
void |
log(int type,
java.lang.String message,
java.lang.Throwable exception)
Logs a new message of the specified type and includes the stack trace of
the specified exception.
|
void |
log(int level,
java.lang.String message,
java.lang.Throwable exception,
java.lang.String userName)
Logs a new message of the specified level tagged to the specified user.
|
static void |
removeClientIp()
Remove client ip address from current thread MDC.
|
static void |
setClientIp(java.lang.String clientIp)
Set client ip address on current thread MDC.
|
void |
setFileAgeLimit(int fileAgeLimit) |
void |
setLogLevel(int logLevel) |
void |
setLogPath(java.lang.String logPath) |
void |
setLogToConsole(boolean logToConsole)
Indicates whether or not log write the messages to the console
|
void |
setRollover(java.lang.String rollover) |
static java.lang.String |
toLevel(int level) |
static int |
toLevel(java.lang.String level) |
void |
warning(java.lang.String message) |
void |
warning(java.lang.String message,
java.lang.String username) |
void |
warning(java.lang.String message,
java.lang.Throwable exception) |
void |
warning(java.lang.String message,
java.lang.Throwable exception,
java.lang.String username) |
public static final java.lang.String LOG_PATTERN
public static final java.lang.String IGNITE_LOG_PATTERN
@Deprecated public static final java.lang.String LOG_PATTERN_NO_IP
public static final java.lang.String MONTHLY
public static final java.lang.String WEEKLY
public static final java.lang.String DAILY
public static final java.lang.String STR_LEVEL_ALL
public static final java.lang.String STR_LEVEL_DEBUG
public static final java.lang.String STR_LEVEL_INFO
public static final java.lang.String STR_LEVEL_WARNING
public static final java.lang.String STR_LEVEL_ERROR
public static final java.lang.String STR_LEVEL_FATAL
public static final java.lang.String STR_LEVEL_OFF
public static final int LEVEL_ALL
public static final int LEVEL_DEBUG
public static final int LEVEL_INFO
public static final int LEVEL_WARNING
public static final int LEVEL_ERROR
public static final int LEVEL_FATAL
public static final int LEVEL_OFF
public static final java.lang.String SERVER_LOG_FILE_NAME
public static final java.lang.String CLIENT_LOG_FILE_NAME
public static Logger getInstance()
public void init(java.lang.String logPath, java.lang.String rolloverSchedule, boolean logToConsole, java.lang.String logLevel, int fileAgeLimit, java.lang.String logFileName)
logPath
- the path of the output filesrolloverSchedule
- the number of days before creating a new log filelogToConsole
- if true, messages will also be written to the consolelogLevel
- assigned level of the LoggerfileAgeLimit
- limit of file age days before we run the rollover files processlogFileName
- file name of the log files to generatepublic boolean loadExternalConfig(java.io.File file)
public void setLogToConsole(boolean logToConsole)
logToConsole
- if true, messages will also be written to the consolepublic void setFileAgeLimit(int fileAgeLimit)
fileAgeLimit
- The fileAgeLimit to set.public void setRollover(java.lang.String rollover)
rollover
- The rollover to set.public void setLogPath(java.lang.String logPath)
logPath
- The logPath to set.public void setLogLevel(int logLevel)
logLevel
- The logLevel to set.public int getLogLevel()
public boolean isAllEnabled()
public boolean isDebugEnabled()
public boolean isInfoEnabled()
public boolean isWarningEnabled()
public boolean isErrorEnabled()
public boolean isFatalEnabled()
public static int toLevel(java.lang.String level)
public static java.lang.String toLevel(int level)
public java.lang.String getLogPath()
public int getFileAgeLimit()
public void log(int type, java.lang.String message)
type
- the type of the messagemessage
- the text of the messagepublic void log(int type, java.lang.String message, java.lang.String userName)
type
- the type of the messagemessage
- the text of the messageuserName
- the user this message will be tagged topublic void log(int type, java.lang.String message, java.lang.Throwable exception)
type
- the type of the messagemessage
- the text of the messageexception
- a Throwable object for which the stack trace must be writtenpublic void log(int level, java.lang.String message, java.lang.Throwable exception, java.lang.String userName)
level
- the level of the messagemessage
- the text of the messageexception
- a Throwable object for which the stack trace must be writtenuserName
- the user this message will be tagged topublic static void setClientIp(java.lang.String clientIp)
public static void removeClientIp()
public void close()
public void all(java.lang.String message)
public void all(java.lang.String message, java.lang.Throwable exception)
public void all(java.lang.String message, java.lang.String username)
public void all(java.lang.String message, java.lang.Throwable exception, java.lang.String username)
public void debug(java.lang.String message)
public void debug(java.lang.String message, java.lang.Throwable exception)
public void debug(java.lang.String message, java.lang.String username)
public void debug(java.lang.String message, java.lang.Throwable exception, java.lang.String username)
public void error(java.lang.String message)
public void error(java.lang.String message, java.lang.Throwable exception)
public void error(java.lang.String message, java.lang.String username)
public void error(java.lang.String message, java.lang.Throwable exception, java.lang.String username)
public void fatal(java.lang.String message)
public void fatal(java.lang.String message, java.lang.Throwable exception)
public void fatal(java.lang.String message, java.lang.String username)
public void fatal(java.lang.String message, java.lang.Throwable exception, java.lang.String username)
public void info(java.lang.String message)
public void info(java.lang.String message, java.lang.Throwable exception)
public void info(java.lang.String message, java.lang.String username)
public void info(java.lang.String message, java.lang.Throwable exception, java.lang.String username)
public void warning(java.lang.String message)
public void warning(java.lang.String message, java.lang.Throwable exception)
public void warning(java.lang.String message, java.lang.String username)
public void warning(java.lang.String message, java.lang.Throwable exception, java.lang.String username)