Package com.illumon.iris.db.util.logging
Class IrisLogCreator
java.lang.Object
com.illumon.iris.db.util.logging.IrisLogCreator
public class IrisLogCreator extends Object
Class to create the standard Iris log objects. It uses a standard set of configuration parameters based on the main class name that
is passed in to the constructor.
First it retrieves the
process.name
property value (this is usually defined by the host configuration).
All property retrieval use a three-tier check:
- First the value is checked with the retrieved process name:
<process name>.<property name>
- Next the value is checked with the passed-in class name:
<mainClassName>.<property name>
- Finally the value is checked for the general value:
IrisLogCreator.<property name>
- If no entries are found for the property an exception will be thrown
.useMainClassNameForLogs
- whether to use the class name for log filenames; if false, then the retrieved property name will be used.logLevel
- the minimum event level to be logged, defaults to INFO.logType
- the type of log, used to determine the type of Logger log that is created, assuming that the code doesn't override this in the constructor. Options include:- STANDARD_LOG_CREATOR - uses the ProcessUnsafeLogCreator to create the Logger instance, this is the default
- CONSOLE - creates a StreamLoggerImpl that sends logs to sysout
- NULL - creates a null Logger implementation that calls any interceptors but doesn't log anything itself
.captureDelegatingLogger
- indicates whether to capture delegating logger output to the Logger instance, defaults to true.captureLog4j
- indicates whether to capture the log4j output to the Logger instance, defaults to false.captureSysout
- indicates whether to capture the sysout output to the Logger instance, defaults to true. Note that if this is true, then the tee interceptor can not be used to send logs to sysout..captureSyserr
- indicates whether to capture the syserr output to the Logger instance, defaults to true.aliveMessageSeconds
- indicates the time in seconds between ALIVE log messages, 0 means no ALIVE messages.writeDatabaseAuditLogs
- if true, use the Iris AuditEventLog.writeDatabaseProcessLogs
- if true, use the Iris ProcessEventLog and send any Logger messages to this log.writeDatabaseProcessInfo
- if true, use the Iris ProcessInfoLog and write the process info to the ProcessInfo table.writeDatabaseProcessMetrics
- if true, use the Iris ProcessMetricsLog and write the process metrics to the ProcessMetrics table.useLogAggregatorService
- if true, use the LogAggregatorService, otherwise log the audit/process events directly to disk.useDynamicPartitions
- if true, use row-based column partition evaluation when logging.logTimeZone
- if set, then use the specified time zone for binary log file names
If using the LogAggregatorService, the standard options for host and port as defined by the LogAggregatorServiceBinaryStoreWriterFactory
(i.e. logAggregatorService.host and logAggregatorService.port, with options for different LAS instances based on namespace and table).
If not using the LogAggregatorService, then the logs are written to <workspace>/../logs/DbInternal/AuditEventLog|ProcessEventLog/<hostname>.bin.*
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IrisLogCreator.LoggerType
The type of Logger to be created -
Field Summary
Fields Modifier and Type Field Description static String
USE_LAS_PROP_SUFFIX
-
Constructor Summary
Constructors Constructor Description IrisLogCreator(com.fishlib.configuration.Configuration configuration, String mainClassName)
Create the standard Iris logs using the default process and audit log parameter namesIrisLogCreator(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, com.fishlib.auth.UserContext userContext, IrisLogCreator.LoggerType loggerType)
Create Deephaven logger instances, including audit event log and process event log if the properties indicate they should be created.IrisLogCreator(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, com.fishlib.auth.UserContext userContext, IrisLogCreator.LoggerType loggerType, boolean forceUseLas)
Create Deephaven logger instances, including audit event log and process event log if the properties indicate they should be created.IrisLogCreator(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, com.fishlib.auth.UserContext userContext, IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs)
Create Deephaven logger instances. -
Method Summary
Modifier and Type Method Description AuditEventLoggerBasic
asAuditEventLoggerBasic()
void
awaitShutdown()
Await shutdown, creating our own OnetimeShutdownTask to log Alive message as appropriate.void
awaitShutdown(com.fishlib.util.process.OnetimeShutdownTask onetimeShutdownTask)
Await shutdown, logging Alive messages as appropriate.void
createEventLoggers(boolean forceUseLas)
Create the process event log, and audit event log, and process metrics log loggers, if specified by the properties.void
createEventLoggers(boolean forceUseLas, boolean standalone)
Create the process event log, and audit event log, and process metrics log loggers, if specified by the properties.AuditEventLogFormat1Logger
getAuditEventLogger()
Return the AuditEventLog loggerString
getBinaryLogTimeZoneName()
Return the binary log time zone nameString
getEventLogHostName()
Return the host name being used for the event logsString
getEventLogProcessName()
Return the host name being used for the event logsString
getFallbackLogFilename()
com.fishlib.io.logger.Logger
getLogger()
Return the Logger instanceProcessEventLogFormat1Logger
getProcessEventLogger()
Return the ProcessEventLog loggerTableWriterLogInterceptor
getProcessLogInterceptor()
Return the ProcessEventLog interceptorcom.fishlib.stats.StatsIntradayLogger
getStatsIntradayLogger()
void
logProcessRunning()
Processes should call this method to indicate that they have finished initialization and are now running.void
registerShutdownMessageTask()
void
registerShutdownMessageTask(AuditEventBuilder auditEventBuilder)
Register the shutdown task that logs the shutting down message.static void
safeLogPelEntry(ProcessEventLogFormat1Logger pelLogger, long timestamp, String host, String level, String process, com.fishlib.auth.UserContext userContext, String logEntry)
Safely log a PEL entry.void
startKeepAliveTask()
Start the keep-alive reporting.
-
Field Details
-
USE_LAS_PROP_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Details
-
IrisLogCreator
public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable com.fishlib.auth.UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType)Create Deephaven logger instances, including audit event log and process event log if the properties indicate they should be created.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processeventLogHostName
- if provided, the host name to be used in the event logs (ProcessEventLog and AuditEventLog). If not provided, then the local host name will be used.eventLogProcessName
- if provided, the process name to be used for the event logs. If not provided, then the process name as derived will be used.userContext
- if provided, the user context for any event logsloggerType
- if provided, the type of Logger desired based on the LoggerType enum
-
IrisLogCreator
public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable com.fishlib.auth.UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, boolean forceUseLas)Create Deephaven logger instances, including audit event log and process event log if the properties indicate they should be created.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processeventLogHostName
- if provided, the host name to be used in the event logs (ProcessEventLog and AuditEventLog). If not provided, then the local host name will be used.eventLogProcessName
- if provided, the process name to be used for the event logs. If not provided, then the process name as derived will be used.userContext
- if provided, the user context for any event logsloggerType
- if provided, the type of Logger desired based on the LoggerType enumforceUseLas
- if true, always use the LogAggregatorService for AEL and PEL instead of relying on the properties
-
IrisLogCreator
public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable com.fishlib.auth.UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs)Create Deephaven logger instances.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processeventLogHostName
- if provided, the host name to be used in the event logs (ProcessEventLog and AuditEventLog). If not provided, then the local host name will be used.eventLogProcessName
- if provided, the process name to be used for the event logs. If not provided, then the process name as derived will be used.userContext
- if provided, the user context for any event logsloggerType
- if provided, the type of Logger desired based on the LoggerType enumforceUseLas
- if true, always use the LogAggregatorService for AEL and PEL instead of relying on the propertiescreateEventLogs
- if true, create audit event logger, process event logger, and process metrics logger instances in this constructor as specified by the properties; if false, creating them and capturing stdout/stderr requires callingcreateEventLoggers(boolean, boolean)
-
IrisLogCreator
public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName)Create the standard Iris logs using the default process and audit log parameter names- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the process
-
-
Method Details
-
getAuditEventLogger
Return the AuditEventLog logger- Returns:
- the AuditEventLog logger or null if none was created
-
getProcessEventLogger
Return the ProcessEventLog logger- Returns:
- the ProcessEventLog logger or null if none was created
-
getStatsIntradayLogger
public com.fishlib.stats.StatsIntradayLogger getStatsIntradayLogger() -
getProcessLogInterceptor
Return the ProcessEventLog interceptor- Returns:
- the ProcessEventLog interceptor or null if none was created
-
getLogger
public com.fishlib.io.logger.Logger getLogger()Return the Logger instance- Returns:
- the Logger instance
-
getEventLogHostName
Return the host name being used for the event logs- Returns:
- the event log host name
-
getEventLogProcessName
Return the host name being used for the event logs- Returns:
- the event log host name
-
getBinaryLogTimeZoneName
Return the binary log time zone name- Returns:
- the binary log time zone name
-
createEventLoggers
public void createEventLoggers(boolean forceUseLas)Create the process event log, and audit event log, and process metrics log loggers, if specified by the properties. These instances are created in parallel.- Parameters:
forceUseLas
- if true, always use the LogAggregatorService for AEL and PEL instead of relying on the properties
-
createEventLoggers
public void createEventLoggers(boolean forceUseLas, boolean standalone)Create the process event log, and audit event log, and process metrics log loggers, if specified by the properties. These instances are created in parallel.- Parameters:
forceUseLas
- if true, always use the LogAggregatorService for AEL and PEL instead of relying on the propertiesstandalone
- if true, don't verify the logger checksums against the schema service
-
startKeepAliveTask
public void startKeepAliveTask()Start the keep-alive reporting. This should not be called when the awaitShutdown methods are being used. -
awaitShutdown
public void awaitShutdown(com.fishlib.util.process.OnetimeShutdownTask onetimeShutdownTask)Await shutdown, logging Alive messages as appropriate. This should not be called if startKeepAliveTask has been called.- Parameters:
onetimeShutdownTask
- the OnetimeShutdownTask
-
awaitShutdown
public void awaitShutdown()Await shutdown, creating our own OnetimeShutdownTask to log Alive message as appropriate. This should not be called if startKeepAliveTask has been called. -
registerShutdownMessageTask
public void registerShutdownMessageTask() -
registerShutdownMessageTask
Register the shutdown task that logs the shutting down message. This must be done after the ProcessEnvironment has been initialized or an IllegalStateException will be thrown. This is not done automatically in the constructor as it's not desirable to enforce creation of the ProcessEnvironment there.- Parameters:
auditEventBuilder
- if provided, log the specified event before stopping the audit event logger
-
logProcessRunning
public void logProcessRunning()Processes should call this method to indicate that they have finished initialization and are now running. A log entry will be written, and if the process is logging to the audit event log then an entry will be added to that table. -
asAuditEventLoggerBasic
-
safeLogPelEntry
public static void safeLogPelEntry(ProcessEventLogFormat1Logger pelLogger, long timestamp, String host, String level, String process, com.fishlib.auth.UserContext userContext, String logEntry) throws IOExceptionSafely log a PEL entry. Binary rows are not allowed to be larger than specified by the property BinaryStoreMaxEntrySize, and if they are, they crash the process. This method will break up entries that are too long into multiple PEL entries.- Parameters:
pelLogger
- the process event loggertimestamp
- the event's timestamphost
- the hostlevel
- the log entry's levelprocess
- the process nameuserContext
- the user context if availablelogEntry
- the log entry, which will be broken up if needed- Throws:
IOException
-
getFallbackLogFilename
-