Customizing Zowe API Mediation Layer logging
Customizing Zowe API Mediation Layer logging
Zowe API Mediation Layer uses logback for its logging.
Configuring logging level
You can manage the volume of API ML logs written to various destinations, such as the standard output streams (stdout, typically viewed in the JES spool on a mainframe), versus dedicated log files on the local file system. You can configure this routing and verbosity for both a single-service deployment or a distributed microservice deployment. Adjust the logging level property by configuring the attribute corresponding to your deployment mode within your zowe.yaml file.
Configuration Examples
For Single-Service Deployment Mode:
Update your zowe.yaml file under the global apiml component block:
# zowe.yaml
components:
apiml:
logging:
level: quiet # Options: quiet | info (default) | debug
For Microservice Deployment Mode: Configure the property under the specific microservice component block (for example, the API Gateway):
# zowe.yaml
components:
gateway:
logging:
level: quiet # Options: quiet | info (default) | debug
This property is similarly supported under components.discovery, components.api-catalog, components.caching-service, and components.zaas.
Log Level Options
Configure the logging verbosity using the following levels:
-
info (default)
Represents the standard, baseline logging configuration. It preserves current operational behavior, writing all standardINFO,WARN, andERRORmessages to the log. -
quiet
Suppresses standardINFO-level chatter to drastically minimize spool usage during normal production operations. This setting retains only selected critical informational messages (such as application startup, component status, and the configured authentication provider), alongside all warnings and errors. -
debug
Provides full diagnostic output for troubleshooting.Backwards CompatibilityLegacy debug parameters remain fully functional for backwards compatibility and take absolute precedence over new
logging.levelsettings.The scope of these legacy overrides depends on your deployment mode:
- Single-Service Deployment: The legacy parameter
components.apiml.debug: truetakes precedence and forces a resolution todebug, overridingcomponents.apiml.logging.level. - Microservice Deployment: Individual service parameters such as
components.gateway.debug: truetake precedence and force a resolution todebugfor that specific microservice, overriding settings likecomponents.gateway.logging.level.
- Single-Service Deployment: The legacy parameter
Log Output Comparisons
The following examples demonstrate how the different logging levels affect the output and volume in your system logs.
Log Output — info level (default)
This level captures standard application milestones alongside framework warnings.
Click here to review an example of info log level.
info level
Notice the inclusion of verbose Tomcat and SpringDoc warning configurations:
2026-07-01 07:20:20.965 <ZWEAGW1:main:33885081> ZWESVUSR INFO (o.z.a.z.s.c.CompoundAuthProvider) ZWEAM105I Using authentication provider: saf
2026-07-01 07:20:27.170 <ZWEAGW1:main:33885081> ZWESVUSR WARN (o.a.t.u.n.j.JSSEUtil) Tomcat interprets the [ciphers] attribute [...]
2026-07-01 07:20:27.301 <ZWEAGW1:Thread-3:33885081> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Discovery Service started in 21.785 seconds
2026-07-01 07:20:27.319 <ZWEAGW1:main:33885081> ZWESVUSR WARN (o.s.c.e.SpringDocAppInitializer) SpringDoc /v3/api-docs endpoint is enabled by default. [...]
2026-07-01 07:20:27.320 <ZWEAGW1:main:33885081> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Caching Service started in 21.805 seconds
2026-07-01 07:20:27.337 <ZWEAGW1:main:33885081> ZWESVUSR INFO (o.z.a.GatewayHealthIndicator) ZWEAM001I API Mediation Layer started
Log Output — quiet level (without errors)
When running normally under the quiet level, routine framework warnings and standard chatter are filtered out. Only critical startup and readiness milestones remain.
Click here to review an example of quiet log level without errors.
quiet level (without errors)
2026-07-01 07:30:09.697 <ZWEAGW1:main:33883157> ZWESVUSR INFO (o.z.a.z.s.c.CompoundAuthProvider) ZWEAM105I Using authentication provider: saf
2026-07-01 07:30:15.951 <ZWEAGW1:Thread-3:33883157> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Discovery Service started in 20.496 seconds
2026-07-01 07:30:15.981 <ZWEAGW1:main:33883157> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Caching Service started in 20.527 seconds
2026-07-01 07:30:15.998 <ZWEAGW1:main:33883157> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I API Catalog Service started in 20.544 seconds
2026-07-01 07:30:15.998 <ZWEAGW1:main:33883157> ZWESVUSR INFO (o.z.a.GatewayHealthIndicator) ZWEAM001I API Mediation Layer started
Log Output — quiet level (with errors)
If an operational issue occurs while using the quiet level, the system dynamically allows relevant WARN and ERROR diagnostics through alongside the core startup sequence.
Click here to review an example of quiet log level with errors.
quiet level (with errors)
2026-07-01 07:34:20.524 <ZWEAGW1:main:33884222> ZWESVUSR INFO (o.z.a.z.s.c.CompoundAuthProvider) ZWEAM105I Using authentication provider: saf
2026-07-01 07:34:26.562 <ZWEAGW1:Thread-3:33884222> ZWESVUSR WARN (o.z.a.d.s.ServiceDefinitionProcessor) ZWEAD702W Unable to process static API definition data: [...]
2026-07-01 07:34:26.563 <ZWEAGW1:Thread-3:33884222> ZWESVUSR ERROR (o.z.a.d.s.StaticServicesRegistrationService) Loading static definition failed: [...]
2026-07-01 07:34:26.563 <ZWEAGW1:Thread-3:33884222> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Discovery Service started in 19.236 seconds
2026-07-01 07:34:26.660 <ZWEAGW1:main:33884222> ZWESVUSR INFO (o.z.a.p.s.ServiceStartupEventHandler) ZWEAM000I Caching Service started in 19.333 seconds
2026-07-01 07:34:43.475 <ZWEAGW1:main:33884222> ZWESVUSR ERROR (o.z.a.c.s.i.ApimlSslKeyExchange) Cannot create server socket: java.net.BindException: EDC8115I Address already in use.
Granular Troubleshooting Options
If a full debug level generates an unmanageable number of log messages, you can utilize the following granular options to restrict output. These options allow you to isolate debug data to a specific file or a specific feature without overwhelming your standard output stream.
Routing Logs to a File
You can configure the system to send logs to a dedicated file, which is recommended when enabling debug features.
To enable logging to a file, add the following to your zowe.yaml or set the equivalent environment variable:
components:
apiml:
logging:
toFile:
enabled: true # Or use environment variable: ZWE_configs_logging_toFile_enabled=true
To keep your standard output stream clean during troubleshooting, you can force only the DEBUG and TRACE level messages to route to the log file:
components:
apiml:
logging:
toFile:
enabled: true
debugOnly: true # Or use environment variable: ZWE_configs_logging_toFile_debugOnly=true
If debugOnly is set to true, but enabled is false, the debugOnly setting is actively ignored.
Feature-Level Debugging
To troubleshoot a specific microservice concept within the single-service deployment, you can target specific features instead of enabling a global debug. Ensure the global components.apiml.debug is set to false, and define your targeted feature under components.apiml.logging.debug:
components:
apiml:
debug: false # The legacy global toggle must be false to use feature-level debugging
logging:
debug:
gateway: false
authentication: true
discovery: true
caching: false
catalog: false
Supported debug features are categorized as follows:
- Core routing and registry:
gateway,discovery,catalog, andcaching - Security operations:
authentication
Enabling any of these feature-specific options automatically includes foundational debug logging for shared API ML features. This configuration ensures that essential system context (such as core framework and infrastructure logs) is captured alongside your targeted feature logs.
Environment variable equivalents:
ZWE_configs_logging_debug_gatewayZWE_configs_logging_debug_authenticationZWE_configs_logging_debug_discoveryZWE_configs_logging_debug_cachingZWE_configs_logging_debug_catalog
The following configuration example demonstrates how to enable debug logs for specific features (authentication, discovery) while keeping the global debug false. To prevent these high-volume logs from overwhelming your standard output stream, they are routed exclusively to a file.
Example:
components:
apiml:
debug: false
logging:
level: quiet
debug:
gateway: false
authentication: true
discovery: true
caching: false
catalog: false
toFile:
enabled: true
debugOnly: true
Configuring granular logging with environment variables
If you are running API Mediation Layer in a containerized environment (such as Docker or Kubernetes) or executing scripts directly, you can pass these granular configurations as environment variables rather than modifying the zowe.yaml file.
This example replicates the exact granular file routing, feature debugging, and class-level loggers presented in the previous YAML examples.
Example with environment variable configuration:
ZWE_configs_logging_toFile_enabled=true
ZWE_configs_logging_toFile_debugOnly=true
ZWE_configs_logging_debug_authentication=true
ZWE_configs_logging_loggerLevels="org.zowe.apiml.zaas.security.service.AuthenticationService=DEBUG,org.zowe.apiml.zaas.security.service.JwtSecurity=DEBUG,org.zowe.apiml.zaas.security.service.token.ApimlAccessTokenProvider=DEBUG"
Advanced XML Customization
To change the default logback configuration file, set components.<component>.logging.config with a path to your logback.xml.
- component
Specifies one of the following services:gatewaydiscoveryapi-catalogcaching-servicezaas
Example with Gateway Service:
components:
gateway:
logging:
config: /path/to/logback.xml
Default logging configuration file
The following logback.xml is an example of logging configuration file which is used by default in all API Mediation Layer components.
Click here for the full logback.xml example.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property resource="application.yml"/>
<property name="MAX_INDEX" value="${rollingPolicy.maxIndex:-12}"/>
<property name="MIN_INDEX" value="${rollingPolicy.minIndex:-1}"/>
<property name="MAX_FILE_SIZE" value="${rollingPolicy.file.maxSize:-50MB}"/>
<property name="STORAGE_LOCATION" value="${apiml.logs.location}"/>
<property name="apimlLogPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS,UTC} %clr<${logbackService:-${logbackServiceName}}:%thread:${PID:- }> %magenta(%X{userid:-}) %cyan(%-5level) %clr\(\(%logger{15}\)\) %msg%n"/>
<turboFilter class="org.zowe.apiml.product.logging.UseridFilter"/>
<springProfile name="!debug & !diag & !dev">
<turboFilter class="org.zowe.apiml.product.logging.ApimlDependencyLogHider"/>
<turboFilter class="org.zowe.apiml.product.logging.LogLevelInfoFilter"/>
<turboFilter class="org.zowe.apiml.product.logging.ApimlDuplicateMessagesFilter">
<AllowedRepetitions>0</AllowedRepetitions>
</turboFilter>
</springProfile>
<conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<charset>${CONSOLE_LOG_CHARSET:-${logging.charset.console:-${file.encoding:-UTF-8}}}</charset>
<layout class="org.zowe.apiml.product.logging.MaskingLogPatternLayout">
<pattern>${apimlLogPattern}</pattern>
</layout>
</encoder>
</appender>
<appender name="FILE" class="org.zowe.apiml.product.logging.ApimlRollingFileAppender">
<file>${STORAGE_LOCATION}/${logbackService:-${logbackServiceName}}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${STORAGE_LOCATION}/${logbackService:-${logbackServiceName}}.%i.log</fileNamePattern>
<minIndex>${MIN_INDEX}</minIndex>
<maxIndex>${MAX_INDEX}</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
</triggeringPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.zowe.apiml.product.logging.MaskingLogPatternLayout">
<pattern>${apimlLogPattern}</pattern>
</layout>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
For more information about the current default logging configuration, see the logback-spring.xml file in the api-layer repository.
Understanding appenders
The default logback.xml configuration defines two appenders:
-
STDOUT
A console appender that prints log messages to standard output. This appender is useful for real-time monitoring and containerized deployments. -
FILE
A rolling file appender that writes log messages to files in the location specified bySTORAGE_LOCATION.The FILE appender uses the value of the
STORAGE_LOCATIONproperty, which is resolved from theapiml.logs.locationsetting in the service'sapplication.yml. By default, this points to<ZOWE_INSTANCE_DIR>/logs/<service>/. You can override this by settingapiml.logs.locationin your configuration.
Root logger level
The <root level="INFO"> element in the default configuration sets the base logging level to INFO for all packages. In this default configuration, only messages at INFO, WARN, and ERROR levels are logged. DEBUG and TRACE messages are suppressed. To change the root level, modify the level attribute:
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
Setting the root level to DEBUG enables verbose logging for all packages, which is useful for troubleshooting but can generate large log volumes.
Customizing the log pattern
One example of possible customization is changing the pattern for the logged messages. The pattern is defined in the apimlLogPattern property in logback.xml. By default, API ML prints log messages, as in the following example.
Example:
2024-08-01 12:52:27.922 <ZWEAGW1:DiscoveryClient-InstanceInfoReplicator-0:33948829> ZWESVUSR INFO (o.z.a.g.h.GatewayHealthIndicator) ZWEAM001 API Mediation Layer started
In the following table you can see each part of the apimlLogPattern in the example of the message above:
| Pattern part | Message part |
|---|---|
%d{yyyy-MM-dd HH:mm:ss.SSS,UTC} | 2024-08-01 12:52:27.922 |
%clr<${logbackService:-${logbackServiceName}}:%thread:${PID:- }> %magenta | <ZWEAGW1:DiscoveryClient-InstanceInfoReplicator-0:33948829> |
(%X{userid:-}) | ZWESVUSR |
%cyan(%-5level) | INFO |
%clr\(\(%logger{15}\)\) | (o.z.a.g.h.GatewayHealthIndicator) |
%msg | ZWEAM001 API Mediation Layer started |
You can edit, move, remove, or add some parts in the pattern based on your requirements.
The full documentation of Logback pattern is available on the Logback site.
Setting log levels using XML
While the loggerLevels property in zowe.yaml is the recommended approach, you can also override the root log level for specific Java packages by mounting a custom logback.xml and adding <logger> elements before the <root> element.
Example of enabling DEBUG logging for specific packages using XML:
<configuration>
<!-- ... existing properties and appenders ... -->
<logger name="org.zowe.apiml.gateway" level="DEBUG"/>
<logger name="org.zowe.apiml.security" level="DEBUG"/>
<logger name="org.springframework.security" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
In this example:
org.zowe.apiml.gatewayandorg.zowe.apiml.securitylog atDEBUGlevel for detailed troubleshooting of Gateway and security operations.org.springframework.securitylogs atDEBUGlevel to help diagnose authentication and authorization issues.- All other packages remain at
INFOlevel as specified by the root logger.
You can optionally set the level to TRACE, WARN, ERROR, or OFF depending on your needs.
Using per-package log levels is the recommended approach for troubleshooting specific issues in production, as these log levels prevent the large log volumes which may result from setting the root level to DEBUG.