hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haohui Mai (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HDFS-9130) Use GenericTestUtils#setLogLevel to the logging level
Date Thu, 24 Sep 2015 06:59:04 GMT

     [ https://issues.apache.org/jira/browse/HDFS-9130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Haohui Mai updated HDFS-9130:
    Summary: Use GenericTestUtils#setLogLevel to the logging level  (was: Use GenericTestUtils#setLogLevel
to set log4j or slf4j logger's level in unit tests)

> Use GenericTestUtils#setLogLevel to the logging level
> -----------------------------------------------------
>                 Key: HDFS-9130
>                 URL: https://issues.apache.org/jira/browse/HDFS-9130
>             Project: Hadoop HDFS
>          Issue Type: Task
>            Reporter: Mingliang Liu
>            Assignee: Mingliang Liu
>         Attachments: HDFS-9130.000.patch
> Currently we use both commons-logging and slf4j in {{hadoop-hdfs}}. To change the logger
level for dumping verbose debug information, there are many unit tests that just cast the
LOG object to a {{Log4JLogger}} and call {{setLevel}} on that. e.g. in {{org.apache.hadoop.fs.TestFcHdfsSetUMask}},
code sample as
> {code}
> ((Log4JLogger)FileSystem.LOG).getLogger().setLevel(Level.DEBUG);
> {code}
> One problem of this hard-coded approach is that we need to update the casting code in
test if we replace the log4j logger with slf4j. For example, as we're creating a separate
jar for hdfs-client (see [HDFS-6200]) which uses only slf4j, we need to replace the log4j
logger with slf4j logger, and to update the casting for changing logger's level in unit tests
as well.
> Instead, we can use the {{GenericTestUtils#setLogLevel}} (brought in [HADOOP-11430])
method for both types of logger. This method internally figures out the right thing to do
based on the log / logger type. e.g.
> {code}
> GenericTestUtils.setLogLevel(FileSystem.LOG, Level.DEBUG);
> {code}

This message was sent by Atlassian JIRA

View raw message