Configuring log rotation

The log rotation parameters define the log level for messages, maximum log file size in megabytes (MB), and the maximum backup count of log files.

About this task

Log rotation parameters can be configured centrally for all components (except for provider instances), or configured separately in their respective configuration files. By default, the log rotation parameters that are defined in the HostFactory service file is propagated to all requestor instances.

The packaged log rotation settings are set to use the propagated values from the host factory service.

A requestor instance uses these propagated values from the host factory parameters when the requestor instance does not specify the log rotation settings in its configuration files. If a requestor instance has its own local log rotation settings, then the requestor instance overrides the propagated values from the host factory.

(7.3.2 Fix)A provider instance uses its own parameters set in the log4j2.xml file available in the provider's configuration folder. For details on log4j2.xml settings, see https://logging.apache.org/log4j/2.x/manual/configuration.html.

Procedure

Configuring log rotation for requestor instances

Procedure

  1. Open the requestor instance configuration file: symAinstreq_config.json ($HF_CONFDIR/providers/symAinst/).
  2. Remove the log_parameters parameter from the symAinstreq_config.json to accept the log rotation configuration from the HostFactory service configuration.
  3. Alternatively, to reject the log rotation configuration propagated from the HostFactory service configuration, include the log_parameters parameter in the symAinstreq_config.json and configure the parameters that you want for the requestor instance:
    "log_parameters":
        {
           "level": "LOG_INFO",
           "max_file_size": 10,
           "max_rotate": 5
        },

Configuring log rotation for provider instances

Procedure

Open the log4j2.xml file in the provider instance configuration location (for example, $HF_CONFDIR/providers/awsinst/log4j2.xml), and locate the RollingFile appenders section. For example:
<Appenders>
   <RollingFile name="FILE_APPEND" fileName="${baseDir1}awsinst-provider.${hostName}.log" filePattern="${baseDir1}awsinst-provider.${hostName}-%d{MM-dd-yyyy}-%i.log.gz" append="true">
      <PatternLayout>
         <Pattern>${logPattern}</Pattern>
      </PatternLayout>
      <Policies>
         <SizeBasedTriggeringPolicy size="10MB" />
      </Policies>
      <DefaultRolloverStrategy max="5"/>
   </RollingFile>
</Appenders>

By default, host factory provider instances use the RollingFile appender. From the example file, note that log rotation is triggered when the file size reaches 10MB, and is set to keep a maximum of five log files.

Customize this configuration or add more policies for different trigger methods. For details on RollingFile appender, refer to the Log4j2 appender documentation.