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
Programming 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 is started, a log file is generated based on the default system configuration. You can also configure custom items and modify log parameters.
Java
Parameter | Description | Valid value |
---|---|---|
rocketmq.log.level | The log level. |
Default value: INFO. |
rocketmq.log.root | The 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.maxIndex | The 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
Parameter | Description | Valid value |
---|---|---|
rocketmq.client.logLevel | The log level. |
Default value: INFO. |
rocketmq.client.logRoot | The 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.logFileName | The name of the log file. | Default value: rocketmq_client_go.log. |
rocketmq.log.file.maxIndex | The maximum number of log files that are retained. | Valid values: 1 to 100. Default value: 10. |
rocketmq.client.logFileMaxSize | The 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.
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()