New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ROCKETMQ-224] add rocketmq client log4j2 logging support #120
Conversation
1 similar comment
2 similar comments
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we put log4j2 test in rocketmq example module ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As log4j is widely used in example,add this test in example will make it confused to choose log moudle.
System.getProperty("rocketmq.client.log.configFile", | ||
System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE")); | ||
System.getProperty("rocketmq.client.log.configFile", | ||
System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you use the right code style? http://rocketmq.apache.org/docs/code-guidelines/
|
||
@Test | ||
public void testLog4j2() { | ||
ClientLogger.getLog().info("logg4j test " + new Date()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any assert or thrown exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert has been added.
2 similar comments
2 similar comments
|
||
package org.apache.rocketmq.client.log; | ||
|
||
import junit.framework.Assert; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better use org.junit.Assert.
private static Logger log; | ||
|
||
static { | ||
log = createLogger(LoggerName.CLIENT_LOGGER_NAME); | ||
public static Class logClass = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add logClass and its getter for test purpose only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it with reflect
@@ -32,15 +33,19 @@ | |||
LOG_DIR = System.getProperty(CLIENT_LOG_ROOT, "${user.home}/logs/rocketmqlogs"); | |||
} | |||
|
|||
// FIXME: Workarond for concret implementation for slf4j, is there any better solution for all slf4j implementations in one class ? 2017/8/1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd better remember this task and fix it later.
Now, LGTM. this pr also fix the rocketmq's logger appender bug when using any concrete implementation, no matter log4j, log4j2 or logback. |
2 similar comments
@@ -99,7 +111,12 @@ private static Logger createLogger(final String loggerName) { | |||
} | |||
|
|||
public static Logger getLog() { | |||
return log; | |||
if (log == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why modify the init method?
Issue apache#120 update brokerStatus See merge request !12
Author: 鲁般 <dezhi.ldz@alibaba-inc.com> Closes apache#120 from lindzh/fix_client_logger.
When using RocketMQ client,we can only using logback or log4j for logging. If we using log4j2,there is no client log.