Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-9130

Use GenericTestUtils#setLogLevel to the logging level

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.8.0, 3.0.0-alpha1
    • 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

        1. HDFS-9130.000.patch
          80 kB
          Mingliang Liu

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            liuml07 Mingliang Liu
            liuml07 Mingliang Liu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment