1 Reply Latest reply on Mar 19, 2013 1:18 PM by vmehrotr

    Rotate Log Files - stdout.log & stderr.log

    Adnan_N

      Hi Folks,

       

      Whats the best way to rotate stdout.log & stderr.log.

       

      I am assuming that rolling of these files can not be configured using felix (please correct me if I am mistaken)

       

      Please advice!

       

      Thanks,

      Adnan

        • 1. Re: Rotate Log Files - stdout.log & stderr.log
          vmehrotr Adobe Employee

          Hi Adnan,

           

          There is currently no way to rotate stdout.log and stderr.log. Therefore, if you want to preserve the stdout.log and stderr.log so that they do not get truncated after restart, add the following commands before any other command in the start script.

           

          # Move stdout.log and stderr.log

          mv ../logs/stdout.log ../logs/stdout_$(date +%Y-%m-%d-%H%M).log

          mv ../logs/stderr.log ../logs/stderr_$(date +%Y-%m-%d-%H%M).log

           

          Another possible way is to disable the stdout.log and stderr.log entirely and instead output the information to the startup.log. Then you can rotate the startup.log instead.

           

          a) To disable the stderr.log and stdout.log, i guess you can add these lines to your crx-quickstart/server/start script:

           

          QUICKSTART_OPTS='-verbose -nobrowser'

          export QUICKSTART_OPTS

           

          b) To configure the path of the startup.log, you can add this to the start script as well (replace /path/to/startup.log with the path you would like the log to be written to instead):

           

          CQ_LOG=/path/to/startup.log

          export CQ_LOG

           

          c) Then after doing this, there is a side effect that crx output will go to the startup.log as well. to fix this, do the following:

            

              1) Go to crx-quickstart/server/runtime/0/_crx/log4j.xml

              2) Comment out this element <appender-ref ref="console" /> from log4j.xml

            

          <root>

          <level value="info" />

          <!-- appender-ref ref="console" /-->

          <appender-ref ref="error" />

          </root>

           

          d) Also, now you would like to rotate the startup.log file:

           

          "The file startup.log logs messages while the Servlet Engine starts. It is usually small, and you cannot configure it."

          The startup log cannot be rotated with CQSE facilities. Please note that logs under /server is rotated at operating system level,

          for more info see http://httpd.apache.org/docs/2.0/programs/rotatelogs.html

           

          Unix workaround :

           

          in serverctl script, replace the line :

           

          exec $jvmExe >> "$CQ_LOG" 2>&1

          by : 

          exec $jvmExe | /usr/sbin/rotatelogs "$CQ_LOG.%Y%m%d" 86400 >> /dev/null 2>&1

           

          If this doesn't seem to work, then try

          exec $jvmExe 2>&1 | /usr/sbin/rotatelogs "$CQ_LOG.%Y%m%d" 86400

           

          Unfortunately, I did not found any workaround for windows system.

           

          Hope this helps.

           

          Thanks,

          Varun