ApsaraMQ for RocketMQ SDKs generate client logs that record runtime events and exceptions. Use these logs to troubleshoot issues during client operation.
Default log file paths
The following table lists the default log file path for each SDK language. {$HOME} is the root directory of the application that you started.
| Language | Default 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 starts, it creates a log file based on default settings. The Java and Go SDKs support custom log parameters. The C++ and C# SDKs do not support custom log configuration.
Java
All Java log parameters are set through JVM system properties (-D flags).
| Parameter | Description | Default | Valid values |
|---|---|---|---|
rocketmq.log.level | Log verbosity level. | INFO | ERROR, WARN, INFO, DEBUG |
rocketmq.log.root | Root directory for log output. | {$HOME}/logs/rocketmq | Any local directory with write permissions. |
rocketmq.log.file.maxIndex | Maximum number of log files to retain. Each log file has a fixed maximum size of 64 MB. | 10 | 1--100. Values outside this range or in an invalid format fall back to the default. |
Make sure that the application process has write permissions on the specified log directory. Otherwise, logs cannot be printed.
Go
Go log parameters are set through environment variables.
| Parameter | Description | Default | Valid values |
|---|---|---|---|
rocketmq.client.logLevel | Log verbosity level. | INFO | ERROR, WARN, INFO, DEBUG |
rocketmq.client.logRoot | Root directory for log output. | {$HOME}/logs/rocketmq | Any local directory with write permissions. |
rocketmq.client.logFileName | Log file name. | rocketmq_client_go.log | Any valid file name. |
rocketmq.log.file.maxIndex | Maximum number of log files to retain. | 10 | 1--100 |
rocketmq.client.logFileMaxSize | Maximum size of each log file. | 1 GB | -- |
Make sure that the application process has write permissions on the specified log directory. Otherwise, logs cannot be printed.
Configure logging
Java
In the startup script or IDE VM options, pass -D flags to set log parameters.
Set the log level to INFO:
java -Drocketmq.log.level=INFO -jar foobar.jarSet a custom log directory and increase file retention:
java -Drocketmq.log.level=WARN \
-Drocketmq.log.root=/var/log/myapp/rocketmq \
-Drocketmq.log.file.maxIndex=20 \
-jar foobar.jarGo
The Go SDK supports two configuration methods:
Static configuration -- Set environment variables before starting the client.
Dynamic configuration -- Set environment variables in code and call
ResetLogger()to apply changes at runtime.
Dynamic configuration (change at runtime):
os.Setenv("rocketmq.client.logLevel", "WARN")
rmq_client.ResetLogger()