Logging to stdout only
In non-container setups, log output is usually written into dedicated log files in the local IAM instance directory. For containerized deployments, however, it is better to send the log information to standard output stdout instead of to local log files. This decouples the application from the infrastructure, and allows the container runtime to automatically capture, rotate, and route logs without risking local storage depletion.
This article explains how to log to stdout only.
Files to be specified:
- The
instance.propertyconfiguration file. For details, see Specifying instance.property below. - The
all-modules.xmllogging configuration file. For details, see Specifying all.modules.xml below.
Specifying instance.property
Three parameters in the instance.property file specify where IAM should write log output. The instance.property file is located in the instances/${instance.name}/ directory.
The following table lists the relevant parameters. It also shows how to configure them in order to write logs to stdout only.
Parameter | Description | Value |
|---|---|---|
| If enabled, writes structured log messages to standard output |
This is the default value for setups based on Docker containers. For details, see Logging parameters. |
| If enabled, writes structured log messages to log files in JSON Lines format. |
This is the default value for setups based on Docker containers. For details, see Logging parameters. |
| If enabled, writes unstructured log messages to files in traditional format. |
This is the default value. |
Switching off appenders in all-modules.xml
In Log4J, appenders define where to log to. To prevent logs from being written to local files, disable the PARSABLE and IAM-AUDIT appenders.
Removing the PARSABLE appender stops log entries from being written to the *-parsable.log files. As a result, the Adminapp log viewer will no longer display log entries.
Perform the following steps:
- Open the
all-modules.xmlfile in theinstances/${instance.name}/log4j/directory. Theall-modules.xmlfile defines central logging settings valid for all IAM modules. - Comment out the following code lines in the
<Loggers>block: <AppenderRef ref=“IAM-AUDIT”/><AppenderRef ref=“PARSABLE”/>
See the following code block. The relevant lines are marked bold and italic:
- After modifying the
instance.propertyand theall-modules.xmlfiles, restart the IAM instance for the changes to take effect. - IAM should now log to
stdoutonly. To verify this, check that log files are no longer written toinstances/${instance.name}/log4j/but instead appear in thestdoutcontainer.
Further information and links
Internal links: