Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

lindzh
Copy link
Contributor

@lindzh lindzh commented Jun 15, 2017

When using RocketMQ client,we can only using logback or log4j for logging. If we using log4j2,there is no client log.

@lindzh lindzh closed this Jun 15, 2017
@lindzh lindzh reopened this Jun 15, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 38.464% when pulling 4b4666a on lindzh:fix_client_logger into 0c5e53d on apache:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 38.464% when pulling 4b4666a on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 39.271% when pulling 4b4666a on lindzh:fix_client_logger into 0c5e53d on apache:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 39.271% when pulling 4b4666a on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 39.271% when pulling 4b4666a on lindzh:fix_client_logger into 0c5e53d on apache:master.

</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
Copy link
Member

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 ?

Copy link
Contributor Author

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"));
Copy link
Member

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());
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert has been added.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.189% when pulling 6ab4ad4 on lindzh:fix_client_logger into 0c5e53d on apache:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.189% when pulling 6ab4ad4 on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.189% when pulling 6ab4ad4 on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.21% when pulling 04e5a1e on lindzh:fix_client_logger into 0c5e53d on apache:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.21% when pulling 04e5a1e on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 39.21% when pulling 04e5a1e on lindzh:fix_client_logger into 0c5e53d on apache:master.


package org.apache.rocketmq.client.log;

import junit.framework.Assert;
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Member

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.

@vongosling
Copy link
Member

Now, LGTM. this pr also fix the rocketmq's logger appender bug when using any concrete implementation, no matter log4j, log4j2 or logback.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 38.771% when pulling 0ea6994 on lindzh:fix_client_logger into 0c5e53d on apache:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 38.771% when pulling 0ea6994 on lindzh:fix_client_logger into 0c5e53d on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 38.771% when pulling 0ea6994 on lindzh:fix_client_logger into 0c5e53d on apache:master.

@@ -99,7 +111,12 @@ private static Logger createLogger(final String loggerName) {
}

public static Logger getLog() {
return log;
if (log == null) {
Copy link
Contributor

@vsair vsair Aug 1, 2017

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?

@asfgit asfgit closed this in 98bd032 Aug 1, 2017
lizhanhui pushed a commit to lizhanhui/rocketmq that referenced this pull request Jun 25, 2019
lizhanhui pushed a commit to lizhanhui/rocketmq that referenced this pull request Jun 25, 2019
Issue apache#120 update brokerStatus



See merge request !12
JiaMingLiu93 pushed a commit to JiaMingLiu93/rocketmq that referenced this pull request May 28, 2020
Author: 鲁般 <dezhi.ldz@alibaba-inc.com>

Closes apache#120 from lindzh/fix_client_logger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants