Details
-
Task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Reviewed
Description
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
((Log4JLogger)FileSystem.LOG).getLogger().setLevel(Level.DEBUG);
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.
GenericTestUtils.setLogLevel(FileSystem.LOG, Level.DEBUG);
Attachments
Attachments
Issue Links
- is required by
-
HDFS-8053 Move DFSIn/OutputStream and related classes to hadoop-hdfs-client
- Resolved