public class CentralLoggerServer extends CentralLogger
ServerDriver.main(java.lang.String[]).| Modifier and Type | Class and Description |
|---|---|
static class |
CentralLoggerServer.Configs
A class to represent all logger configs for the server.
|
static class |
CentralLoggerServer.ConfigsBuilder
Builder class for
CentralLoggerServer.Configs |
CentralLogger.MdcVar, CentralLogger.Mode, CentralLogger.Slf4jKey| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<java.lang.String,org.slf4j.Logger> |
clientLoggerNameSlf4jPairs
Map of client logger name : slf4j logger instance pairs for clients sending logs server-side.
|
private static java.util.Map<java.lang.Long,java.util.logging.FileHandler> |
clientPidFileHandlerPairs
Map of client process id : FileHandler pairs
|
private static CentralLoggerServer.Configs |
configs
Configs for all instances of the logger.
|
private static java.util.logging.Level |
DEFAULT_SPAWNER_LEVEL
The default logger level for spawner processes.
|
private static java.util.concurrent.atomic.AtomicBoolean |
isLogicalTerminalInitialized
Flag to indicate if the LogicalTerminal has been initialized.
|
private static CentralLogger |
LOG
Logger.
|
private static java.util.logging.Formatter |
LOG_FORMATTER
The log formatter.
|
private static int |
MISSING_COUNT_CONFIG_PLACEHOLDER
Placeholder for log files count, when no config value.
|
private static int |
MISSING_LIMIT_CONFIG_PLACEHOLDER
Placeholder for log files size, when no config value.
|
private static java.util.logging.FileHandler |
serverFileHandler
The file handler, responsible for writing server logs to files.
|
private static java.lang.String |
SPAWNER_LOGGER_NAME
The logger name for the redirected System.err from the spawn process.
|
private static java.util.concurrent.atomic.AtomicInteger |
SPAWNER_THREAD_COUNTER
Counter for unique name for the spawner logger Thread.
|
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 |
|---|
CentralLoggerServer(java.lang.String loggerName,
java.util.logging.Level level,
boolean checkParentLevels,
boolean excludeSMContext)
Package-private constructor for CentralLoggerServer.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) static void |
closeFiles()
On JVM shutdown closes log files.
|
static CentralLoggerServer.Configs |
getConfigs()
Return the server configs.
|
static void |
initialize(CentralLoggerServer.Configs configs)
Initializer.
|
static boolean |
isLogicalTerminalInitialized()
Returns a flag to indicate if the LogicalTerminal has been initialized.
|
static void |
logSpawnerStream(java.io.InputStream stream,
java.util.concurrent.atomic.AtomicBoolean isSpawnerRunning)
Creates an unique name for the logger Thread, parsing the spawner input stream and passes the spawner
logger details to the log method.
|
static CentralLoggerClientConfig |
prepareClientConfig()
Returns the configs for initializing logging on the client.
|
protected void |
publish(ContextLogRecord logRecord)
Publishes a log record.
|
(package private) static void |
publishClientLog(CentralLogRecord clr)
Publishes the log record from a client process to its dedicated file handler.
|
static void |
removeHandler(long clientPid)
Removes the client process log file handler.
|
static void |
setLogicalTerminalInitialized(boolean isLogicalTerminalInitialized)
Flag to indicate if the LogicalTerminal has been initialized.
|
(package private) static void |
setupClientHandler(java.lang.String filePath,
int rotationLimit,
int rotationCount,
long pid,
java.lang.String userOS,
java.lang.String appServerName)
Creates and configures a file handler for the specified client process.
|
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 CentralLogger LOG
private static final java.util.logging.Formatter LOG_FORMATTER
private static final java.lang.String SPAWNER_LOGGER_NAME
private static final java.util.concurrent.atomic.AtomicInteger SPAWNER_THREAD_COUNTER
private static final java.util.logging.Level DEFAULT_SPAWNER_LEVEL
private static final int MISSING_COUNT_CONFIG_PLACEHOLDER
private static final int MISSING_LIMIT_CONFIG_PLACEHOLDER
private static final java.util.Map<java.lang.Long,java.util.logging.FileHandler> clientPidFileHandlerPairs
private static final java.util.Map<java.lang.String,org.slf4j.Logger> clientLoggerNameSlf4jPairs
private static final java.util.concurrent.atomic.AtomicBoolean isLogicalTerminalInitialized
private static volatile CentralLoggerServer.Configs configs
private static volatile java.util.logging.FileHandler serverFileHandler
CentralLoggerServer(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 initialize(CentralLoggerServer.Configs configs)
configs - All configs needed to create log files and set the root logger level.public static CentralLoggerServer.Configs getConfigs()
public static void logSpawnerStream(java.io.InputStream stream,
java.util.concurrent.atomic.AtomicBoolean isSpawnerRunning)
stream - The input stream with log messages coming from the spawner.isSpawnerRunning - Atomic boolean to flag if the spawner is still running.public static CentralLoggerClientConfig prepareClientConfig()
static void setupClientHandler(java.lang.String filePath,
int rotationLimit,
int rotationCount,
long pid,
java.lang.String userOS,
java.lang.String appServerName)
filePath - The path to the log file.rotationLimit - The file limit, or the max bytes in a log file before rotation.rotationCount - The file count, or the max number of files before file overwrite starts.pid - The process id of the client.userOS - The OS user.appServerName - The appServer name.static void publishClientLog(CentralLogRecord clr)
clr - The central log record.static void closeFiles()
public static void removeHandler(long clientPid)
clientPid - The client process ID.public static void setLogicalTerminalInitialized(boolean isLogicalTerminalInitialized)
isLogicalTerminalInitialized - A flag to indicate if the LogicalTerminal has been initialized.public static boolean isLogicalTerminalInitialized()
true if the LogicalTerminal has been initialized, false otherwise.protected void publish(ContextLogRecord logRecord)
publish in class CentralLoggerlogRecord - The log record.