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

Support quiet/verbose bin/solr options for changing log level

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.2
    • Fix Version/s: 6.3, 7.0
    • Component/s: scripts and tools
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:

      Description

      Spinoff from SOLR-6677

      Let's make it much easier to "turn on debug" by supporting a bin/solr start -V verbose option, and likewise a bin/solr start -q for quiet operation.

      These would simply be convenience options for changing the RootLogger from level INFO to DEBUG or WARN respectively. This can be done programmatically in log4j at startup.

      Could be we need to add some more package specific defaults in log4j.properties to get the right mix of logs

      1. SOLR-9534.patch
        10 kB
        Jan Høydahl
      2. SOLR-9534.patch
        8 kB
        Jan Høydahl

        Issue Links

          Activity

          Hide
          erickerickson Erick Erickson added a comment -

          +1

          Show
          erickerickson Erick Erickson added a comment - +1
          Hide
          janhoy Jan Høydahl added a comment -

          Attaching patch:

          • We support the new environment variable SOLR_LOG_LEVEL which may be set either in solr.in.cmd|sh or in the shell. If the start scripts finds a value for SOLR_LOG_LEVEL it will pass it on to Solr as option -Dsolr.log.level=$SOLR_LOG_LEVEL
          • In SolrDispatchFilter.init() we check the option, and change the rootLogger level programmatically
          • Adds two new arguments to bin/solr[.cmd]: -v and -q which sets SOLR_LOG_LEVEL to DEBUG and WARN respectively. These will override whatever set in the environment.

          So now you don't need to understand Log4J or dig to find the correct log config to make Solr verbose or quiet.

          Only Linux script tested. Would be grateful if someone would take solr.cmd for a ride. I do not validate the env.var, but a single-word invalid level will simply select the default which is INFO.

          Show
          janhoy Jan Høydahl added a comment - Attaching patch: We support the new environment variable SOLR_LOG_LEVEL which may be set either in solr.in.cmd|sh or in the shell. If the start scripts finds a value for SOLR_LOG_LEVEL it will pass it on to Solr as option -Dsolr.log.level=$SOLR_LOG_LEVEL In SolrDispatchFilter.init() we check the option, and change the rootLogger level programmatically Adds two new arguments to bin/solr[.cmd] : -v and -q which sets SOLR_LOG_LEVEL to DEBUG and WARN respectively. These will override whatever set in the environment. So now you don't need to understand Log4J or dig to find the correct log config to make Solr verbose or quiet. Only Linux script tested. Would be grateful if someone would take solr.cmd for a ride. I do not validate the env.var, but a single-word invalid level will simply select the default which is INFO.
          Hide
          janhoy Jan Høydahl added a comment -

          The -q flag logs with WARN level. With this patch, it will produce this for bin/solr start -f -q

          Starting Solr on port 8983 from /Users/janhoy/git/lucene-solr/solr/server
          
          0    INFO  (main) [   ] o.e.j.s.Server jetty-9.3.8.v20160314
          198  WARN  (main) [   ] o.e.j.s.SecurityHandler ServletContext@o.e.j.w.WebAppContext@6536e911{/solr,file:///Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp/,STARTING}{/Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp} has uncovered http methods for path: /
          205  INFO  (main) [   ] o.a.s.s.SolrDispatchFilter Log level override, property solr.log.level=WARN
          298  WARN  (main) [   ] o.a.s.c.CoreContainer Couldn't add files from /Users/janhoy/git/lucene-solr/solr/server/solr/lib to classpath: /Users/janhoy/git/lucene-solr/solr/server/solr/lib
          553  INFO  (main) [   ] o.e.j.s.h.ContextHandler Started o.e.j.w.WebAppContext@6536e911{/solr,file:///Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp/,AVAILABLE}{/Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp}
          566  INFO  (main) [   ] o.e.j.s.ServerConnector Started ServerConnector@57250572{HTTP/1.1,[http/1.1]}{0.0.0.0:8983}
          567  INFO  (main) [   ] o.e.j.s.Server Started @986ms
          

          PS: The two WARN logs are removed over in SOLR-8186, as well as printing date&time in console log.

          A problem with just switching to WARN is that we pretty much mute everything Solr has to say The easiest solution is to explicitly set log level to INFO for a few selected Solr classes which we still want to see. Or long term implement the ideas from SOLR-4132

          Show
          janhoy Jan Høydahl added a comment - The -q flag logs with WARN level. With this patch, it will produce this for bin/solr start -f -q Starting Solr on port 8983 from /Users/janhoy/git/lucene-solr/solr/server 0 INFO (main) [ ] o.e.j.s.Server jetty-9.3.8.v20160314 198 WARN (main) [ ] o.e.j.s.SecurityHandler ServletContext@o.e.j.w.WebAppContext@6536e911{/solr,file:///Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp/,STARTING}{/Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp} has uncovered http methods for path: / 205 INFO (main) [ ] o.a.s.s.SolrDispatchFilter Log level override, property solr.log.level=WARN 298 WARN (main) [ ] o.a.s.c.CoreContainer Couldn't add files from /Users/janhoy/git/lucene-solr/solr/server/solr/lib to classpath: /Users/janhoy/git/lucene-solr/solr/server/solr/lib 553 INFO (main) [ ] o.e.j.s.h.ContextHandler Started o.e.j.w.WebAppContext@6536e911{/solr,file:///Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp/,AVAILABLE}{/Users/janhoy/git/lucene-solr/solr/server/solr-webapp/webapp} 566 INFO (main) [ ] o.e.j.s.ServerConnector Started ServerConnector@57250572{HTTP/1.1,[http/1.1]}{0.0.0.0:8983} 567 INFO (main) [ ] o.e.j.s.Server Started @986ms PS: The two WARN logs are removed over in SOLR-8186 , as well as printing date&time in console log. A problem with just switching to WARN is that we pretty much mute everything Solr has to say The easiest solution is to explicitly set log level to INFO for a few selected Solr classes which we still want to see. Or long term implement the ideas from SOLR-4132
          Hide
          janhoy Jan Høydahl added a comment -

          Tested on Windows 10
          I plan to commit this tomorrow, please voice any concerns.
          PS: These start options are of course just an alternative to the existing, i.e. selecting another log4j.properties or editing the default one.

          Show
          janhoy Jan Høydahl added a comment - Tested on Windows 10 I plan to commit this tomorrow, please voice any concerns. PS: These start options are of course just an alternative to the existing, i.e. selecting another log4j.properties or editing the default one.
          Hide
          janhoy Jan Høydahl added a comment -

          New patch which takes advantage of the new class StartupLoggingUtils

          Show
          janhoy Jan Høydahl added a comment - New patch which takes advantage of the new class StartupLoggingUtils
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 73c2edddf01dbbd312d9101a9e1e1db1e4c7e770 in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=73c2edd ]

          SOLR-9534: You can now set Solr's log level through environment variable SOLR_LOG_LEVEL and -q and -v options to bin/solr

          Show
          jira-bot ASF subversion and git services added a comment - Commit 73c2edddf01dbbd312d9101a9e1e1db1e4c7e770 in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=73c2edd ] SOLR-9534 : You can now set Solr's log level through environment variable SOLR_LOG_LEVEL and -q and -v options to bin/solr
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 97bb81db1a84983137e44f0dd753c411c925a2ea in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=97bb81d ]

          SOLR-9534: You can now set Solr's log level through environment variable SOLR_LOG_LEVEL and -q and -v options to bin/solr

          (cherry picked from commit 73c2edd)

          Show
          jira-bot ASF subversion and git services added a comment - Commit 97bb81db1a84983137e44f0dd753c411c925a2ea in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=97bb81d ] SOLR-9534 : You can now set Solr's log level through environment variable SOLR_LOG_LEVEL and -q and -v options to bin/solr (cherry picked from commit 73c2edd)
          Show
          janhoy Jan Høydahl added a comment - Documented options in RefGuide: https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=50234737&selectedPageVersions=51&selectedPageVersions=50 https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=32604193&selectedPageVersions=25&selectedPageVersions=24
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 8648fd5e83ce6aa6978e6841a89778bf72d02e26 in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8648fd5 ]

          SOLR-9534: Fix typo in help, said "-V or -version", but should be "-V or -verbose"

          Show
          jira-bot ASF subversion and git services added a comment - Commit 8648fd5e83ce6aa6978e6841a89778bf72d02e26 in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8648fd5 ] SOLR-9534 : Fix typo in help, said "-V or -version", but should be "-V or -verbose"
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit f3cbc1a7ab61de2655f01bcc61dfc17e6959cf0f in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=f3cbc1a ]

          SOLR-9534: Fix typo in help, said "-V or -version", but should be "-V or -verbose"

          (cherry picked from commit 8648fd5)

          Show
          jira-bot ASF subversion and git services added a comment - Commit f3cbc1a7ab61de2655f01bcc61dfc17e6959cf0f in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=f3cbc1a ] SOLR-9534 : Fix typo in help, said "-V or -version", but should be "-V or -verbose" (cherry picked from commit 8648fd5)
          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:
              janhoy Jan Høydahl
              Reporter:
              janhoy Jan Høydahl
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development