Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9500

Add a @LogLevel attribute to change log levels on tests

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.3
    • Component/s: Tests
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      It would be useful to be able to set log levels to higher granularity for specific tests by adding an annotation to the test class or method, rather than having to muck around with log4j properties files.

      1. SOLR-9500.patch
        11 kB
        Alan Woodward
      2. SOLR-9500.patch
        11 kB
        Alan Woodward

        Activity

        Hide
        romseygeek Alan Woodward added a comment -

        This patch adds a LogLevel annotation that can be added to any test class or method on a class that extends SolrTestCaseJ4. Configuration looks like this:

        @LogLevel("org.apache.solr=WARN;org.apache.solr.core.CoreContainer=DEBUG")
        

        The original log levels for any Loggers changed by this annotation are recorded and then reset once the method or test class has finished executing.

        Show
        romseygeek Alan Woodward added a comment - This patch adds a LogLevel annotation that can be added to any test class or method on a class that extends SolrTestCaseJ4. Configuration looks like this: @LogLevel( "org.apache.solr=WARN;org.apache.solr.core.CoreContainer=DEBUG" ) The original log levels for any Loggers changed by this annotation are recorded and then reset once the method or test class has finished executing.
        Hide
        dsmiley David Smiley added a comment -

        Cool. Maybe this annotation should be on the ForbiddenApi list so we don't accidentally commit these?

        Show
        dsmiley David Smiley added a comment - Cool. Maybe this annotation should be on the ForbiddenApi list so we don't accidentally commit these?
        Hide
        romseygeek Alan Woodward added a comment -

        I was thinking that it would sometimes be useful to commit this, for example for a flaky test that won't fail locally - just up the log level on Jenkins for that specific test.

        Show
        romseygeek Alan Woodward added a comment - I was thinking that it would sometimes be useful to commit this, for example for a flaky test that won't fail locally - just up the log level on Jenkins for that specific test.
        Hide
        romseygeek Alan Woodward added a comment -

        Here's a better patch, isolating all the log4j-specific code to the LogLevel annotation file.

        Show
        romseygeek Alan Woodward added a comment - Here's a better patch, isolating all the log4j-specific code to the LogLevel annotation file.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 45fcd396f7a2f59538c11d01fd745e4f1ff6a172 in lucene-solr's branch refs/heads/branch_6x from Alan Woodward
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=45fcd39 ]

        SOLR-9500: Add LogLevel annotation for test-specific logging changes

        Show
        jira-bot ASF subversion and git services added a comment - Commit 45fcd396f7a2f59538c11d01fd745e4f1ff6a172 in lucene-solr's branch refs/heads/branch_6x from Alan Woodward [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=45fcd39 ] SOLR-9500 : Add LogLevel annotation for test-specific logging changes
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit c809cd4f0a67dc620876073e0debdcdf8f012834 in lucene-solr's branch refs/heads/master from Alan Woodward
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=c809cd4 ]

        SOLR-9500: Add LogLevel annotation for test-specific logging changes

        Show
        jira-bot ASF subversion and git services added a comment - Commit c809cd4f0a67dc620876073e0debdcdf8f012834 in lucene-solr's branch refs/heads/master from Alan Woodward [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=c809cd4 ] SOLR-9500 : Add LogLevel annotation for test-specific logging changes
        Hide
        shalinmangar Shalin Shekhar Mangar added a comment -

        Closing after 6.3.0 release.

        Show
        shalinmangar Shalin Shekhar Mangar added a comment - Closing after 6.3.0 release.

          People

          • Assignee:
            romseygeek Alan Woodward
            Reporter:
            romseygeek Alan Woodward
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development