[
https://issues.apache.org/jira/browse/HADOOP-13470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15423563#comment-15423563
]
Mingliang Liu commented on HADOOP-13470:
----------------------------------------
Thanks [~cnauroth] for the report and analysis. Sorry I was not aware of the
case that captured logs format matters besides the application log itself.
A simple fix is to use default {{PatternLayout}} only if the {{stdout}} and
{{console}} appender are not defined. This should not make the existing code
fail; and guards the cases where those appenders are not defined. At least, if
an incoming test relys on the log format, it should define the format in
module-specific log4j.properties. If this looks good, I can prepare a simple
patch for this.
{{TestBootstrapStandby#testSharedEditsMissingLogs}} asserts the log level
(FATAL), which is the same problem. Thanks [~kihwal] for reporting this. This
was also missed in pre-commit build.
{code}
private LogCapturer(Logger logger) {
this.logger = logger;
- this.appender = new WriterAppender(new PatternLayout(), sw);
- logger.addAppender(appender);
+ Appender defaultAppender = Logger.getRootLogger().getAppender("stdout");
+ if (defaultAppender == null) {
+ defaultAppender = Logger.getRootLogger().getAppender("console");
+ }
+ final Layout layout = (defaultAppender == null) ? new PatternLayout() :
defaultAppender.getLayout();
+ this.appender = new WriterAppender(layout, sw);
+ logger.addAppender(this.appender);
}
{code}
> GenericTestUtils$LogCapturer is flaky
> -------------------------------------
>
> Key: HADOOP-13470
> URL: https://issues.apache.org/jira/browse/HADOOP-13470
> Project: Hadoop Common
> Issue Type: Bug
> Components: test, util
> Affects Versions: 2.8.0
> Reporter: Mingliang Liu
> Assignee: Mingliang Liu
> Labels: reviewed
> Fix For: 2.8.0
>
> Attachments: HADOOP-13470.000.patch, HADOOP-13470.001.patch
>
>
> {{GenericTestUtils$LogCapturer}} is useful for assertions against service
> logs. However it should be fixed in following aspects:
> # In the constructor, it uses the stdout appender's layout.
> {code}
> Layout layout = Logger.getRootLogger().getAppender("stdout").getLayout();
> {code}
> However, the stdout appender may be named "console" or alike which makes the
> constructor throw NPE. Actually the layout does not matter and we can use a
> default pattern layout that only captures application logs.
> # {{stopCapturing()}} method is not working. The major reason is that the
> {{appender}} internal variable is never assigned and thus removing it to stop
> capturing makes no sense.
> # It does not support {{org.slf4j.Logger}} which is preferred to log4j in
> many modules.
> # There is no unit test for it.
> This jira is to address these.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]