Package com.illumon.iris.db.util.logging
Class IrisLogCreator
java.lang.Object
com.illumon.iris.db.util.logging.IrisLogCreator
- All Implemented Interfaces:
DataImportServerLogFactory
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.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 ClassesModifier and TypeClassDescriptionstatic enum
The type of Logger to be created -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionIrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName) Deprecated.IrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName, boolean createAuditEventLogger) Create the standard Iris logs using the default process and audit log parameter names.IrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, String eventLogProcessInfoId, UserContext userContext, IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs) Deprecated.IrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, String eventLogProcessInfoId, UserContext userContext, IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs, boolean createAuditEventLogger) Create Deephaven logger instances.IrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, String eventLogProcessInfoId, UserContext userContext, IrisLogCreator.LoggerType loggerType, io.deephaven.process.ProcessInfo processInfo, boolean forceUseLas, boolean createEventLogs) Deprecated.IrisLogCreator
(com.fishlib.configuration.Configuration configuration, String mainClassName, String eventLogHostName, String eventLogProcessName, String eventLogProcessInfoId, UserContext userContext, IrisLogCreator.LoggerType loggerType, io.deephaven.process.ProcessInfo processInfo, boolean forceUseLas, boolean createEventLogs, boolean createAuditEventLogger) Create Deephaven logger instances. -
Method Summary
Modifier and TypeMethodDescriptionGets the audit event logger to use for this DataImportServer.void
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.void
createEventLoggers
(boolean forceUseLas, boolean standalone, boolean captureStdoutEarly) 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, boolean captureStdoutEarly, boolean allowLogCreationFailure) Create the process event log, and audit event log, and process metrics log loggers, if specified by the properties.static IrisLogCreator
createIrisLogCreatorSingleton
(com.fishlib.configuration.Configuration configuration, String mainClassName, boolean createAuditEventLogger) Create the standard Iris logs using the default process and audit log parameter names and register it as the singleton.Return the AuditEventLog loggerReturn the binary log time zone nameReturn the host name being used for the event logsReturn the unique process info id used for the event logsReturn the process name being used for the event logscom.fishlib.io.logger.Logger
Return the Logger instancestatic IrisLogCreator
getOrCreateIrisLogCreatorSingleton
(com.fishlib.configuration.Configuration configuration, String mainClassName, boolean createAuditEventLogger) Return the registered singleton, or create the standard Iris logs using the default process and audit log parameter names and register it as the singleton.Return the ProcessEventLog loggerReturn the ProcessEventLog interceptorstatic IrisLogCreator
io.deephaven.enterprise.stats.StatsIntradayLogger
void
Processes should call this method to indicate that they have finished initialization and are now running.void
Register the shutdown message task.void
registerShutdownMessageTask
(AuditEventBuilder auditEventBuilder) Register the shutdown task that logs the shutting down message.static void
safeLogPelEntry
(ProcessEventLogFormat2Logger pelLogger, long timestamp, String host, String level, String process, String processInfoId, UserContext userContext, String logEntry) Safely log a PEL entry.static IrisLogCreator
setSingleton
(IrisLogCreator instance) void
setUserContext
(UserContext userContext) Allow the user context (used inasAuditEventLoggerBasic()
to be set after initialization.void
Start the keep-alive reporting.
-
Field Details
-
USE_MAIN_CLASS_NAME_PROP_SUFFIX
- See Also:
-
LOG_LEVEL_PROP_SUFFIX
- See Also:
-
LOG_TYPE_PROP_SUFFIX
- See Also:
-
CAPTURE_LOG4J_PROP_SUFFIX
- See Also:
-
CAPTURE_DELEGATING_LOGGER_PROP_SUFFIX
- See Also:
-
CAPTURE_SYSERR_PROP_SUFFIX
- See Also:
-
ALIVE_TIME_PROP_SUFFIX
- See Also:
-
SHUTDOWN_WAIT_MILLISECONDS_SUFFIX
- See Also:
-
WRITE_DATABASE_PROCESS_LOGS_PROP_SUFFIX
- See Also:
-
WRITE_PROCESS_INFO_PROP_SUFFIX
- See Also:
-
WRITE_PROCESS_METRICS_PROP_SUFFIX
- See Also:
-
USE_LAS_PROP_SUFFIX
- See Also:
-
USE_DYNAMIC_PARTITIONS_SUFFIX
- See Also:
-
TIME_ZONE_SUFFIX
- See Also:
-
-
Constructor Details
-
IrisLogCreator
@Deprecated public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName) Deprecated.Create the standard Iris logs using the default process and audit log parameter names. This won't create an audit event logger.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the process
-
IrisLogCreator
public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, boolean createAuditEventLogger) Create the standard Iris logs using the default process and audit log parameter names.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processcreateAuditEventLogger
- if true, create an audit event logger
-
IrisLogCreator
@Deprecated public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable String eventLogProcessInfoId, @Nullable UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs) Deprecated.Create Deephaven logger instances. This won't create an audit event logger.- 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.eventLogProcessInfoId
- The unique process id to be used for the event logs. If not provided, one will be generated.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, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable String eventLogProcessInfoId, @Nullable UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, boolean forceUseLas, boolean createEventLogs, boolean createAuditEventLogger) 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.eventLogProcessInfoId
- The unique process id to be used for the event logs. If not provided, one will be generated.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)
createAuditEventLogger
- if true, create an audit event logger
-
IrisLogCreator
@Deprecated public IrisLogCreator(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable String eventLogProcessInfoId, @Nullable UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, @Nullable io.deephaven.process.ProcessInfo processInfo, boolean forceUseLas, boolean createEventLogs) Deprecated.Create Deephaven logger instances. This won't create an audit event logger.- 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.eventLogProcessInfoId
- The unique process id to be used for the event logs. If not provided, one will be generated.userContext
- If provided, the user context for any event logsloggerType
- If provided, the type of Logger desired based on the LoggerType enumprocessInfo
- If provided, the process info to be used for this process.forceUseLas
- 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, @Nullable String eventLogHostName, @Nullable String eventLogProcessName, @Nullable String eventLogProcessInfoId, @Nullable UserContext userContext, @Nullable IrisLogCreator.LoggerType loggerType, @Nullable io.deephaven.process.ProcessInfo processInfo, boolean forceUseLas, boolean createEventLogs, boolean createAuditEventLogger) 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.eventLogProcessInfoId
- The unique process id to be used for the event logs. If not provided, one will be generated.userContext
- If provided, the user context for any event logsloggerType
- If provided, the type of Logger desired based on the LoggerType enumprocessInfo
- If provided, the process info to be used for this process.forceUseLas
- 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)
createAuditEventLogger
- if true, create the audit event logger whenever the event logs are created (now or through a later createEventLoggers call)
-
-
Method Details
-
setSingleton
-
getSingleton
-
getAuditEventLogger
Return the AuditEventLog logger- Specified by:
getAuditEventLogger
in interfaceDataImportServerLogFactory
- 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 io.deephaven.enterprise.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- Specified by:
getLogger
in interfaceDataImportServerLogFactory
- Returns:
- the Logger instance
-
getEventLogHostName
Return the host name being used for the event logs- Returns:
- the event log host name
-
getEventLogProcessName
Return the process name being used for the event logs- Returns:
- the event log process name
-
getEventLogProcessInfoId
Return the unique process info id used for the event logs- Returns:
- the process info id for the event logs
-
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
-
createEventLoggers
public void createEventLoggers(boolean forceUseLas, boolean standalone, boolean captureStdoutEarly) 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 servicecaptureStdoutEarly
- if true, capture stdout/stderr/log4j early - like to prevent noise on a command line tool. if false, delay a little to make debugging regular processes easier
-
createEventLoggers
public void createEventLoggers(boolean forceUseLas, boolean standalone, boolean captureStdoutEarly, boolean allowLogCreationFailure) 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 servicecaptureStdoutEarly
- if true, capture stdout/stderr/log4j early - like to prevent noise on a command line tool. if false, delay a little to make debugging regular processes easierallowLogCreationFailure
- if true, it is not fatal to fail to create the binary loggers. Check withgetAuditEventLogger()
andgetProcessEventLogger()
-
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. -
createIrisLogCreatorSingleton
public static IrisLogCreator createIrisLogCreatorSingleton(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, boolean createAuditEventLogger) Create the standard Iris logs using the default process and audit log parameter names and register it as the singleton.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processcreateAuditEventLogger
- if true, create the audit event logger whenever the event logs are created (now or through a later createEventLoggers call)- Returns:
- the IrisLogCreator instance
-
getOrCreateIrisLogCreatorSingleton
public static IrisLogCreator getOrCreateIrisLogCreatorSingleton(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull String mainClassName, boolean createAuditEventLogger) Return the registered singleton, or create the standard Iris logs using the default process and audit log parameter names and register it as the singleton.- Parameters:
configuration
- a Configuration instancemainClassName
- the main class for the processcreateAuditEventLogger
- if true, create the audit event logger whenever the event logs are created (now or through a later createEventLoggers call)- Returns:
- the IrisLogCreator instance
-
registerShutdownMessageTask
public void registerShutdownMessageTask()Register the shutdown message task. -
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
Description copied from interface:DataImportServerLogFactory
Gets the audit event logger to use for this DataImportServer.- Specified by:
asAuditEventLoggerBasic
in interfaceDataImportServerLogFactory
- Returns:
- the audit event logger to use for this data import server.
-
setUserContext
Allow the user context (used inasAuditEventLoggerBasic()
to be set after initialization.- Parameters:
userContext
- the new userContext to use in logging.
-
safeLogPelEntry
public static void safeLogPelEntry(ProcessEventLogFormat2Logger pelLogger, long timestamp, String host, String level, String process, String processInfoId, UserContext userContext, String logEntry) throws IOException Safely 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 nameprocessInfoId
- the unique identifier for the processuserContext
- the user context if availablelogEntry
- the log entry, which will be broken up if needed- Throws:
IOException
- from logging events
-
getFallbackLogFilename
-