- Environment variables — adjust log levels for specific packages without redeploying a config file
- Config file — full control over appenders, patterns, and per-logger levels
Configure with environment variables
The default config reads these env vars. Set any of them in your deployment to adjust levels without touching the config file:
To switch to JSON output for log aggregation, set
LOG4J2_APPENDER_LAYOUT=json.
Use a config file
To further customize your logging at an individual logger-level, you can use a custom log4j configuration file. First, bind your custom log4j configuration file to the/app/resources/log4j2.xml path in the container.
Then set the JAVA_TOOL_OPTIONS environment variable to point the JVM at your file. Without it, Gateway ignores the mounted file and falls back to its built-in configuration: