public class CentralLoggerClient extends CentralLogger
ClientDriver.main(java.lang.String[]) and sending logs to the server.CentralLogger.MdcVar, CentralLogger.Mode, CentralLogger.Slf4jKey| Modifier and Type | Field and Description |
|---|---|
private static long |
clientPid
This client process ID.
|
private static java.lang.String |
clientUserOs
This client process OS user ID.
|
private static java.util.Queue<CentralLogRecord> |
LOG_BUFFER
Thread-safe queue to store logs before being sent to the server on state sync or logger finish.
|
private static CentralLogService |
logService
The remote log service on the server to receive the leftover log messages on
finish(). |
private static java.lang.Integer |
sessionId
The server session ID.
|
private static java.lang.String |
userId
The server user ID.
|
DEFAULT_CLIENT_LOG_FILE_NAME, DEFAULT_FILE_COUNT, DEFAULT_FILE_LIMIT_BYTES, DEFAULT_ROOT_LEVEL, DEFAULT_SERVER_LOG_FILE_NAME, IS_LOGGER_WORK_FINISHED, JVM_ARG_ENABLE_SLF4j_API, MIN_FILE_COUNT, MIN_FILE_LIMIT_BYTES, WRITE_TO_SLF4J_API| Constructor and Description |
|---|
CentralLoggerClient(java.lang.String loggerName,
java.util.logging.Level level,
boolean checkParentLevels,
boolean excludeSMContext)
Package-private constructor for CentralLoggerClient.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
finish()
Allows graceful completion of logger work.
|
(package private) static java.util.List<java.util.logging.LogRecord> |
getLeftoverLogs()
Returns a List of all logs present in the buffer converted to CentralLogRecord.
|
static CentralLogService |
getLogService()
Returns the server log service.
|
static java.lang.Integer |
getSessionId()
Returns the remote server session ID.
|
static java.lang.String |
getUserId()
Returns the remote server user ID.
|
protected void |
publish(ContextLogRecord logRecord)
Publishes a log record.
|
static CentralLogRecord[] |
pullLogs()
Copies all logs currently in the buffer to an array and returns it.
|
private static void |
pushLogs(CentralLogRecord[] logRecords)
Adds log records to the buffer.
|
static void |
setLogService(CentralLogService logService)
Static setter for
logService. |
static void |
setPid(long clientPid)
Sets this client process ID.
|
static void |
setupFileHandler(java.lang.String filePath,
int fileLimit,
int fileCount,
java.lang.String appServerName)
Creates and configures a file handler for the specified client process.
|
static void |
setUserOs(java.lang.String clientUserOs)
Sets this client process OS user ID.
|
addToPreInitBuffer, all, completePreInitWork, config, equals, findLevel, fine, fine, finer, finest, generate, get, get, get, getExplicitLevel, getLevel, getLoggerLevelMap, getLoggerName, getMode, getRootLevel, getSlf4jLogBuilder, handleShutDown, hashCode, info, info, initializeClient, isCheckParentLevels, isClient, isExcludeSMContext, isLoggable, log, log, log, log, log, logp, logp, logStream, logToSlf4j, setBootstrapConfig, setFileHandler, setLevel, setLevels, setMode, severe, severe, warning, warning, warningprivate static final java.util.Queue<CentralLogRecord> LOG_BUFFER
private static volatile CentralLogService logService
finish(). Not used for other logs, otherwise causes infinite recursion.private static volatile long clientPid
private static volatile java.lang.String clientUserOs
private static volatile java.lang.Integer sessionId
private static volatile java.lang.String userId
CentralLoggerClient(java.lang.String loggerName,
java.util.logging.Level level,
boolean checkParentLevels,
boolean excludeSMContext)
loggerName - The name of the logger.level - The level of the logger.checkParentLevels - Flag to prevent recursion for class loaders.excludeSMContext - Flag to prevent deadlock on SecurityManager.public static void setLogService(CentralLogService logService)
logService.logService - The log service.public static CentralLogService getLogService()
public static void setPid(long clientPid)
clientPid - This client process ID.public static void setUserOs(java.lang.String clientUserOs)
clientUserOs - This client process OS user ID.public static java.lang.Integer getSessionId()
public static java.lang.String getUserId()
public static void finish()
logService has not been set, it leaves
it to CentralLogger.handleShutDown(), which is usually called later. Otherwise, the leftover
logs, still not synced to the server, are pushed over rpc and a flag is raised to disable further
logging, thus avoiding recursion.public static CentralLogRecord[] pullLogs()
static java.util.List<java.util.logging.LogRecord> getLeftoverLogs()
private static void pushLogs(CentralLogRecord[] logRecords)
logRecords - An array of log records.public static void setupFileHandler(java.lang.String filePath,
int fileLimit,
int fileCount,
java.lang.String appServerName)
filePath - The path to the log file.fileLimit - The file limit, or the max bytes in a log file before rotation.fileCount - The file count, or the max number of files before file overwrite starts.appServerName - The appServer name.protected void publish(ContextLogRecord logRecord)
publish in class CentralLoggerlogRecord - A log record.