hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mingliang Liu (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HDFS-9130) Use GenericTestUtils#setLogLevel to set log4j or slf4j logger's level in unit tests
Date Wed, 23 Sep 2015 23:36:04 GMT
Mingliang Liu created HDFS-9130:
-----------------------------------

             Summary: Use GenericTestUtils#setLogLevel to set log4j or slf4j logger's level
in unit tests
                 Key: HDFS-9130
                 URL: https://issues.apache.org/jira/browse/HDFS-9130
             Project: Hadoop HDFS
          Issue Type: Task
            Reporter: Mingliang Liu
            Assignee: Mingliang Liu


Currently we use both commons-logging and slf4j in {{hadoop-hdfs}}. To change the 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.
{code}
((Log4JLogger)LOG).getLogger().setLevel(Level.ALL);
{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(LOG, Level.ALL);
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message