Client logs record and help you troubleshoot exceptions that occur during the running of ApsaraMQ for RocketMQ clients. This topic describes how to view and configure client logs of ApsaraMQ for RocketMQ SDKs.

Default path of log files

The following table describes the default path of client logs for various programming languages.
Note {$HOME} is the root directory of the application that you started.
Programming languageDefault path
Java{$HOME}/logs/rocketmq/rocketmq-client.log
C++{$HOME}/logs/rocketmq/client.log
C#{$HOME}/logs/rocketmq/rocketmq-client.log
Go{$HOME}/logs/rocketmq/rocketmq_client_go.log

Log parameters

After the client is started, a log file is generated based on the default system configuration. You can also configure custom items and modify log parameters.

Note You can not configure custom items for client logs for C++ and C#.

Java

ParameterDescriptionValid value
rocketmq.log.levelThe log level.
  • ERROR
  • WARN
  • INFO
  • DEBUG

Default value: INFO.

rocketmq.log.rootThe root directory of the logs. Default value: {$HOME}/logs/rocketmq.

{$HOME} is the root directory of the Java process that you started. You can set this parameter to your local directory.

Note Make sure that your application process is granted write permissions on the path. Otherwise, logs cannot be printed.
rocketmq.log.file.maxIndexThe maximum number of log files that are retained. Valid values: 1 to 100. Default value: 10.

If the specified value is not within this range or in an invalid format, the default value provided by the system is used.

The maximum size of a log file is 64 MB and cannot be changed.

Go

ParameterDescriptionValid value
rocketmq.client.logLevelThe log level.
  • ERROR
  • WARN
  • INFO
  • DEBUG

Default value: INFO.

rocketmq.client.logRootThe root directory of the logs. Default value: {$HOME}/logs/rocketmq.

{$HOME} is the root directory of the Go process that you started. You can set this parameter to your local directory.

Note Make sure that your application process is granted write permissions on the path. Otherwise, logs cannot be printed.
rocketmq.client.logFileNameThe name of the log file. Default value: rocketmq_client_go.log.
rocketmq.log.file.maxIndexThe maximum number of log files that are retained. Valid values: 1 to 100. Default value: 10.
rocketmq.client.logFileMaxSizeThe maximum size of a log file. Default value: 1 GB.

Sample configuration

You can modify system parameters to configure custom items for the SDK for Java and the SDK for Go. For information about log parameters, see Log parameters.

Sample configuration of the SDK for Java

In the startup script or the virtual machine (VM) options of the integrated development environment (IDE), run the -D command to configure client logs.

The following sample code provides an example in which the rocketmq.log.level parameter is set to INFO:
java -Drocketmq.log.level=INFO -jar foobar.jar

Sample configuration of the SDK for Go

  • Static configuration: Configure log parameters in the environment variables and start the client for Go.
  • Dynamic configuration: Configure log parameters in the code and call the ResetLogger() operation.
    The following sample code provides an example in which the rocketmq.log.level parameter is set to WARN:
    os.Setenv("rocketmq.client.logLevel", "WARN")
    rmq_client.ResetLogger()