RocketMq客户端日志参数设置

使用的RocketMq版本为4.7.1
RocketMq的客户端日志打印,Logger的创建代码在org.apache.rocketmq.client.log.ClientLogger中,部分代码如下:

public static final String CLIENT_LOG_USESLF4J = "rocketmq.client.logUseSlf4j";
public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot";
public static final String CLIENT_LOG_MAXINDEX = "rocketmq.client.logFileMaxIndex";
public static final String CLIENT_LOG_FILESIZE = "rocketmq.client.logFileMaxSize";
public static final String CLIENT_LOG_LEVEL = "rocketmq.client.logLevel";
public static final String CLIENT_LOG_ADDITIVE = "rocketmq.client.log.additive";
public static final String CLIENT_LOG_FILENAME = "rocketmq.client.logFileName";
public static final String CLIENT_LOG_ASYNC_QUEUESIZE = "rocketmq.client.logAsyncQueueSize";
public static final String ROCKETMQ_CLIENT_APPENDER_NAME = "RocketmqClientAppender";
 
String clientLogRoot = System.getProperty(CLIENT_LOG_ROOT, System.getProperty("user.home") + "/logs/rocketmqlogs");
String clientLogMaxIndex = System.getProperty(CLIENT_LOG_MAXINDEX, "10");
String clientLogFileName = System.getProperty(CLIENT_LOG_FILENAME, "rocketmq_client.log");
String maxFileSize = System.getProperty(CLIENT_LOG_FILESIZE, "1073741824");
String asyncQueueSize = System.getProperty(CLIENT_LOG_ASYNC_QUEUESIZE, "1024");
 
String clientLogLevel = System.getProperty(CLIENT_LOG_LEVEL, "INFO");
boolean additive = "true".equalsIgnoreCase(System.getProperty(CLIENT_LOG_ADDITIVE));

通过在JVM启动参数中添加-Dparam=xxx或者代码启动类中调用System.setProperty(“param”, xxx)即可达到参数设置效果

参数释义:

rocketmq.client.logUseSlf4j:默认为false,如果这个设置为true,那下面其他的日志参数都无效了。因为会使用slf4j来创建日志对象实例(LOGGER_NAME=RocketmqClient),可以认为和应用程序使用同样的日志配置
rocketmq.client.logRoot:日志根目录,默认是$USER_HOME/Logs/rocketmqLogs
rocketmq.client.logFileMaxIndex:最大保留的日志文件数量,默认10
rocketmq.client.logFileMaxSize:日志文件最大大小限制,默认1G
rocketmq.client.logLevel:日志等级,默认INFO
rocketmq.client.log.additive:类似log4j的additive设置,表示子logger是否继承父logger的所有appenders,默认false。在这里没有什么意义
rocketmq.client.logFileName:日志文件名,默认是rocketmq_client.log
rocketmq.client.logAsyncQueueSize:异步缓冲队列大小,默认1024

你可能感兴趣的:(备忘,RocketMq,rocketmq,客户端日志)