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

solr.log written to {solrRoot}/server/logs instead of location specified by SOLR_LOGS_DIR

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.2, 6.0.1
    • Fix Version/s: 6.3, 7.0
    • Component/s: logging
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None
    • Environment:

      64-bit CentOS 7 with latest patches, JVM 1.8.0.92

      Description

      (6.1 is probably also affected, but we've been blocked by SOLR-9231)

      solr.log should be written to the directory specified by the SOLR_LOGS_DIR environment variable, but instead it's written to

      {solrRoot}

      /server/logs.

      This results in requiring that solr is installed on a writable device, which leads to two problems:
      1) solr installation can't live on a shared device (single copy shared by two or more VMs)
      2) solr installation is more difficult to lock down

      Solr should be able to run without error in this test scenario:

      burn the Solr directory tree onto a CD-ROM
      Mount this CD as /solr
      run Solr from there (with appropriate environment variables set, of course)

      1. SOLR-9325-installscript.patch
        0.7 kB
        Jan Høydahl
      2. SOLR-9325.patch
        8 kB
        Jan Høydahl
      3. SOLR-9325.patch
        9 kB
        Jan Høydahl
      4. SOLR-9325.patch
        4 kB
        Jan Høydahl

        Issue Links

          Activity

          Hide
          janhoy Jan Høydahl added a comment -

          Tested this on master now.
          Changing SOLR_LOGS_DIR in solr.in.sh will cause console and gc logs to go to the new dir, but not solr.log which is hardcoded in log4j.properties.

          However, this is clearly documented in solr.in.sh, so user is told how to fix it. Still I think we should try to somehow propagate the env.var into the log4j file

          Show
          janhoy Jan Høydahl added a comment - Tested this on master now. Changing SOLR_LOGS_DIR in solr.in.sh will cause console and gc logs to go to the new dir, but not solr.log which is hardcoded in log4j.properties . However, this is clearly documented in solr.in.sh, so user is told how to fix it. Still I think we should try to somehow propagate the env.var into the log4j file
          Hide
          janhoy Jan Høydahl added a comment -

          First patch. Sets -Dsolr.log.dir=$SOLR_LOGS_DIR in start script and uses variable ${solr.log.dir} in log4j.properties. Default still set to relative "logs".

          NOT tested at all on Windows (anyone?), tested some on macOS

          Show
          janhoy Jan Høydahl added a comment - First patch. Sets -Dsolr.log.dir=$SOLR_LOGS_DIR in start script and uses variable ${solr.log.dir} in log4j.properties. Default still set to relative "logs". NOT tested at all on Windows (anyone?), tested some on macOS
          Hide
          janhoy Jan Høydahl added a comment -

          Updated patch with Windows fixes:

          • SOLR_LOGS_DIR was always overwritten in solr.cmd
          • Did not support space in the path
          • Check for restricted folders now works
          • Missed set in solr.in.cmd

          Tested on Windows 10 with and without spaces in SOLR_LOGS_DIR.

          Please review and test. Plan to commit in a few days.

          Show
          janhoy Jan Høydahl added a comment - Updated patch with Windows fixes: SOLR_LOGS_DIR was always overwritten in solr.cmd Did not support space in the path Check for restricted folders now works Missed set in solr.in.cmd Tested on Windows 10 with and without spaces in SOLR_LOGS_DIR. Please review and test. Plan to commit in a few days.
          Hide
          janhoy Jan Høydahl added a comment -

          Fix UTF-8 BOM for solr.cmd

          Show
          janhoy Jan Høydahl added a comment - Fix UTF-8 BOM for solr.cmd
          Hide
          janhoy Jan Høydahl added a comment -

          Tim Parker would you be able to test this in your environment?

          Show
          janhoy Jan Høydahl added a comment - Tim Parker would you be able to test this in your environment?
          Hide
          tparker Tim Parker added a comment -

          I'd be happy to - but I haven't installed anything other than full builds - and I don't have the dev environment set up... I have 6.2.1 installed - can you send me the replacement file(s)?

          Show
          tparker Tim Parker added a comment - I'd be happy to - but I haven't installed anything other than full builds - and I don't have the dev environment set up... I have 6.2.1 installed - can you send me the replacement file(s)?
          Hide
          janhoy Jan Høydahl added a comment -

          I made a 6.3.0-SNAPSHOT build from current branch_6x with this patch added, and uploaded to https://dl.dropboxusercontent.com/u/20080302/solr-6.3.0-SNAPSHOT.tgz
          MD5 checksum: dc6a7ec7b2d6daf6016588134772ce31
          SHA checksum: e434d14e49bb5965bfbb3e105210fa4c1a5178ee

          Show
          janhoy Jan Høydahl added a comment - I made a 6.3.0-SNAPSHOT build from current branch_6x with this patch added, and uploaded to https://dl.dropboxusercontent.com/u/20080302/solr-6.3.0-SNAPSHOT.tgz MD5 checksum: dc6a7ec7b2d6daf6016588134772ce31 SHA checksum: e434d14e49bb5965bfbb3e105210fa4c1a5178ee
          Hide
          tparker Tim Parker added a comment -

          Installed the snapshot... chasing a couple of unrelated things on my end, but what I've seen so far is:

          1) the logs all appear to go into the right place
          2) Solr is creating an empty directory '2' under the '.../server' directory - not sure if this relates to the specified home directory being empty at startup, but... it shouldn't be there

          some config info:
          SOLR_PID_DIR = /home/content/private/keys
          SOLR_LOGS_DIR = /home/content/private/logs
          startup command line: /opt/solr/latest/bin/solr start -s /home/content/private/solr -p 8987 -force
          /opt/solr/latest is a symlink to /media/sf_common/solr/latest, which is itself a symbolic link to the latest Solr build

          /media/sf_common is a VirtualBox shared folder

          Show
          tparker Tim Parker added a comment - Installed the snapshot... chasing a couple of unrelated things on my end, but what I've seen so far is: 1) the logs all appear to go into the right place 2) Solr is creating an empty directory '2' under the '.../server' directory - not sure if this relates to the specified home directory being empty at startup, but... it shouldn't be there some config info: SOLR_PID_DIR = /home/content/private/keys SOLR_LOGS_DIR = /home/content/private/logs startup command line: /opt/solr/latest/bin/solr start -s /home/content/private/solr -p 8987 -force /opt/solr/latest is a symlink to /media/sf_common/solr/latest, which is itself a symbolic link to the latest Solr build /media/sf_common is a VirtualBox shared folder
          Hide
          janhoy Jan Høydahl added a comment - - edited

          Thanks for testing the build.
          The empty server/2 folder is a bug in bin/solr where I used 2&>/dev/null instead of 2>/dev/null to redirect stderr. You can fix it with this oneliner:

          sed -i "" 's|2&>/dev/null|2>/dev/null|g' bin/solr
          
          Show
          janhoy Jan Høydahl added a comment - - edited Thanks for testing the build. The empty server/2 folder is a bug in bin/solr where I used 2&>/dev/null instead of 2>/dev/null to redirect stderr. You can fix it with this oneliner: sed -i "" 's|2&>/dev/ null |2>/dev/ null |g' bin/solr
          Hide
          janhoy Jan Høydahl added a comment -

          I welcome any other comments on this approach. Plan to commit on friday.

          The only weakness I can see with this now is

          • If Solr is started in another way than through bin/solr, people will need to supply -Dsolr.log.dir manually
          • If someone use another log framework than log4j, they are on their own. If that framework supports var substitution they can insert a ${solr.log.dir} in the config
          • Windows part only tested on Windows 10, could it break with other windows versions?
          Show
          janhoy Jan Høydahl added a comment - I welcome any other comments on this approach. Plan to commit on friday. The only weakness I can see with this now is If Solr is started in another way than through bin/solr, people will need to supply -Dsolr.log.dir manually If someone use another log framework than log4j, they are on their own. If that framework supports var substitution they can insert a ${solr.log.dir} in the config Windows part only tested on Windows 10, could it break with other windows versions?
          Hide
          tparker Tim Parker added a comment -

          that fixed it... thank you.

          Show
          tparker Tim Parker added a comment - that fixed it... thank you.
          Hide
          tparker Tim Parker added a comment -

          further testing shows that the logs all appear to be going to the right places - I haven't tried this on Windows 7 yet, but I have seen several other (apparently unrelated) problems with 6.3 including '...possible analysis error...' when indexing PDF (as parsed by Tika), and some AlreadyClosedException entries - should I write these up separately? or are these just fallout from this being an interim build?

          Show
          tparker Tim Parker added a comment - further testing shows that the logs all appear to be going to the right places - I haven't tried this on Windows 7 yet, but I have seen several other (apparently unrelated) problems with 6.3 including '...possible analysis error...' when indexing PDF (as parsed by Tika), and some AlreadyClosedException entries - should I write these up separately? or are these just fallout from this being an interim build?
          Hide
          janhoy Jan Høydahl added a comment -

          If you see other issues with 6.3-SNAPSHOT, please report it on the solr-user mailing list or directly in JIRA if you are certain it is a bug.
          I normally search http://search-lucene.com/?fc_project=Solr&fc_project=Lucene&q= for the error msg to try to locate an existing JIRA before creating a new one.

          Show
          janhoy Jan Høydahl added a comment - If you see other issues with 6.3-SNAPSHOT, please report it on the solr-user mailing list or directly in JIRA if you are certain it is a bug. I normally search http://search-lucene.com/?fc_project=Solr&fc_project=Lucene&q= for the error msg to try to locate an existing JIRA before creating a new one.
          Hide
          tallison@mitre.org Tim Allison added a comment -

          And for Tika-specific errors, please ping us on our JIRA. Thank you!

          Show
          tallison@mitre.org Tim Allison added a comment - And for Tika-specific errors, please ping us on our JIRA. Thank you!
          Hide
          tparker Tim Parker added a comment -

          will do - we're calling Tika ourselves, so this probably isn't a Tika issue, but... I know where to find you if it is - thank you!

          Show
          tparker Tim Parker added a comment - will do - we're calling Tika ourselves, so this probably isn't a Tika issue, but... I know where to find you if it is - thank you!
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 33db4de4d7d5e325f8bfd886d3957735b33310a8 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=33db4de ]

          SOLR-9325: solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties

          Show
          jira-bot ASF subversion and git services added a comment - Commit 33db4de4d7d5e325f8bfd886d3957735b33310a8 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=33db4de ] SOLR-9325 : solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit bc5e06e34cd6c6d45668fff9969305b1ae8e1ce1 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=bc5e06e ]

          SOLR-9325: solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties

          (cherry picked from commit 33db4de)

          Show
          jira-bot ASF subversion and git services added a comment - Commit bc5e06e34cd6c6d45668fff9969305b1ae8e1ce1 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=bc5e06e ] SOLR-9325 : solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties (cherry picked from commit 33db4de)
          Hide
          janhoy Jan Høydahl added a comment -

          Pushed. Thanks to Tim for reporting and testing!

          Show
          janhoy Jan Høydahl added a comment - Pushed. Thanks to Tim for reporting and testing!
          Hide
          janhoy Jan Høydahl added a comment -

          The bin/install_solr_service.sh script does a search/replace to hardcode solr.log in log4j.properties. This is not necessary anymore, and also breaks if people later modify solr.in.sh, here is a patch (SOLR-9325-installscript.patch).

          Show
          janhoy Jan Høydahl added a comment - The bin/install_solr_service.sh script does a search/replace to hardcode solr.log in log4j.properties. This is not necessary anymore, and also breaks if people later modify solr.in.sh , here is a patch ( SOLR-9325 -installscript.patch).
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit c9cf0eff03763d151a04baccb5530445d5d5feb5 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=c9cf0ef ]

          SOLR-9325: Remove unnecessary search/replace in installer script

          Show
          jira-bot ASF subversion and git services added a comment - Commit c9cf0eff03763d151a04baccb5530445d5d5feb5 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=c9cf0ef ] SOLR-9325 : Remove unnecessary search/replace in installer script
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit b907e56923ef2619d619a31c92dd00d3b6598349 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=b907e56 ]

          SOLR-9325: Remove unnecessary search/replace in installer script

          (cherry picked from commit c9cf0ef)

          Show
          jira-bot ASF subversion and git services added a comment - Commit b907e56923ef2619d619a31c92dd00d3b6598349 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=b907e56 ] SOLR-9325 : Remove unnecessary search/replace in installer script (cherry picked from commit c9cf0ef)
          Show
          janhoy Jan Høydahl added a comment - Documented in RefGuide https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=32604193&selectedPageVersions=26&selectedPageVersions=25 https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=50856198&selectedPageVersions=50&selectedPageVersions=49
          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:
              tparker Tim Parker
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development