Class IrisLogCreator

java.lang.Object
com.illumon.iris.db.util.logging.IrisLogCreator
All Implemented Interfaces:
DataImportServerLogFactory

public class IrisLogCreator extends Object implements 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
The following properties are provided (all following the three-tier check for retrieval - just the suffixes are listed here):
  • .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 &lt;workspace&gt;/../logs/DbInternal/AuditEventLog|ProcessEventLog/&lt;hostname&gt;.bin.*

  • Field Details

  • 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 instance
      mainClassName - 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 instance
      mainClassName - the main class for the process
      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, boolean forceUseLas, boolean createEventLogs)
      Deprecated.
      Create Deephaven logger instances. This won't create an audit event logger.
      Parameters:
      configuration - A Configuration instance
      mainClassName - The main class for the process
      eventLogHostName - 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 logs
      loggerType - If provided, the type of Logger desired based on the LoggerType enum
      forceUseLas - If true, always use the LogAggregatorService for AEL and PEL instead of relying on the properties
      createEventLogs - 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 calling createEventLoggers(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 instance
      mainClassName - The main class for the process
      eventLogHostName - 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 logs
      loggerType - If provided, the type of Logger desired based on the LoggerType enum
      forceUseLas - If true, always use the LogAggregatorService for AEL and PEL instead of relying on the properties
      createEventLogs - 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 calling createEventLoggers(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 instance
      mainClassName - The main class for the process
      eventLogHostName - 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 logs
      loggerType - If provided, the type of Logger desired based on the LoggerType enum
      processInfo - 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 properties
      createEventLogs - 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 calling createEventLoggers(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 instance
      mainClassName - The main class for the process
      eventLogHostName - 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 logs
      loggerType - If provided, the type of Logger desired based on the LoggerType enum
      processInfo - 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 properties
      createEventLogs - 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 calling createEventLoggers(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

      public static IrisLogCreator setSingleton(@Nullable IrisLogCreator instance)
    • getSingleton

      public static IrisLogCreator getSingleton()
    • getAuditEventLogger

      public AuditEventLogFormat3Logger getAuditEventLogger()
      Return the AuditEventLog logger
      Specified by:
      getAuditEventLogger in interface DataImportServerLogFactory
      Returns:
      the AuditEventLog logger or null if none was created
    • getProcessEventLogger

      public ProcessEventLogFormat2Logger getProcessEventLogger()
      Return the ProcessEventLog logger
      Returns:
      the ProcessEventLog logger or null if none was created
    • getStatsIntradayLogger

      public io.deephaven.enterprise.stats.StatsIntradayLogger getStatsIntradayLogger()
    • getProcessLogInterceptor

      public TableWriterLogInterceptor 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 interface DataImportServerLogFactory
      Returns:
      the Logger instance
    • getEventLogHostName

      public String getEventLogHostName()
      Return the host name being used for the event logs
      Returns:
      the event log host name
    • getEventLogProcessName

      public String getEventLogProcessName()
      Return the process name being used for the event logs
      Returns:
      the event log process name
    • getEventLogProcessInfoId

      public String getEventLogProcessInfoId()
      Return the unique process info id used for the event logs
      Returns:
      the process info id for the event logs
    • getBinaryLogTimeZoneName

      public String 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 properties
      standalone - 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 properties
      standalone - if true, don't verify the logger checksums against the schema service
      captureStdoutEarly - 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 properties
      standalone - if true, don't verify the logger checksums against the schema service
      captureStdoutEarly - 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
      allowLogCreationFailure - if true, it is not fatal to fail to create the binary loggers. Check with getAuditEventLogger() and getProcessEventLogger()
    • 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 instance
      mainClassName - the main class for the process
      createAuditEventLogger - 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 instance
      mainClassName - the main class for the process
      createAuditEventLogger - 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

      public void registerShutdownMessageTask(@Nullable AuditEventBuilder auditEventBuilder)
      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

      public AuditEventLoggerBasicEx asAuditEventLoggerBasic()
      Description copied from interface: DataImportServerLogFactory
      Gets the audit event logger to use for this DataImportServer.
      Specified by:
      asAuditEventLoggerBasic in interface DataImportServerLogFactory
      Returns:
      the audit event logger to use for this data import server.
    • setUserContext

      public void setUserContext(UserContext userContext)
      Allow the user context (used in asAuditEventLoggerBasic() 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 logger
      timestamp - the event's timestamp
      host - the host
      level - the log entry's level
      process - the process name
      processInfoId - the unique identifier for the process
      userContext - the user context if available
      logEntry - the log entry, which will be broken up if needed
      Throws:
      IOException - from logging events
    • getFallbackLogFilename

      public String getFallbackLogFilename()