All Products
Search
Document Center

ApsaraMQ for RocketMQ:Client logging

Last Updated:Mar 11, 2026

Client logs record runtime exceptions from ApsaraMQ for RocketMQ clients. Use these logs to locate and troubleshoot issues.

Enable log printing

The TCP client SDK for Java uses the SLF4J API for logging. Dependency requirements vary by SDK version:

  • SDK for Java 1.7.8.Final or later: Log printing is enabled by default. The SDK has a built-in logging implementation -- no additional dependencies are needed.

  • SDK for Java earlier than 1.7.8.Final: Add a logging implementation dependency to your pom.xml or lib directory. These versions support Log4j and Logback only, not Log4j2. We recommend that you use the latest version of ApsaraMQ for RocketMQ SDK for Java to print client logs.

Important

If your application includes both Log4j and Logback as dependencies, client logs cannot be printed due to logging conflicts. Keep only one logging implementation. To check, run:

mvn clean dependency:tree | grep log

Default configuration

When the client starts, it generates log files with the following defaults:

  • Log file path: /{user.home}/logs/ons.log, where {user.home} is the home directory of the account running the current Java process

  • Log level: INFO

  • Max historical log files: 10

  • Single log file size: 64 MB (not configurable)

Configuration parameters

Override defaults by passing JVM -D flags in your startup script or IDE VM options.

Parameter

Default

Valid values

Description

ons.client.logRoot

/{user.home}/logs/

Any writable path

Root directory for log files. Make sure the application process has write permissions on this path.

ons.client.logLevel

INFO

ERROR, WARN, INFO, DEBUG

Log verbosity level.

ons.client.logFileMaxIndex

10

1--100

Maximum number of historical log files to retain. Values outside this range or in an invalid format fall back to the default (10).

Configure client logs

Important

Custom log configuration requires SDK for Java 1.2.5 or later.

Pass -D flags in the startup script or IDE VM options to override defaults.

Linux:

-Dons.client.logRoot=/home/admin/logs -Dons.client.logLevel=WARN -Dons.client.logFileMaxIndex=20

Windows:

-Dons.client.logRoot=D:\logs -Dons.client.logLevel=WARN -Dons.client.logFileMaxIndex=20

Replace /home/admin/logs and D:\logs with your actual log directory paths.