Expand my Community achievements bar.

SOLVED

Need to append current date to error.log file name

Avatar

Level 2

Hi,

Could you please explain me, how can I append the current date to error.log file. Something like error-DD-MM-YYYY.log.

Thanks,

Phalgun

1 Accepted Solution

Avatar

Correct answer by
Administrator

check this:- How to enable log-rotation for the error.log

//

To reconfigure the error.log of CRX, simply edit the log4j.xml configuration file of the CRX webapp. This is located beneath the /WEB-INF folder of the deployed CRX webapp.

Please edit the section for the error appender and do the following:

  • change the class of the appender to org.apache.log4j.RollingFileAppender
  • add additional parameter maxBackupIndex to define the maximum number of rotated log-files to keep (default: 1 if missing)
  • optional: add parameter maxFileSize to limit the maximum file size of a rotated log-file (default: 10MB if missing)

Excerpt from log4j.xml

<appender name="error" class="org.apache.log4j.RollingFileAppender">

    <param name="maxBackupIndex" value="5" />

    <param name="File" value="crx-quickstart/logs/crx/error.log"/>

    <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>

    </layout>

</appender>

This change will take effect after a repository restart. For more information, please refer to [1].

[1]Log4jXmlFormat - Logging-log4j Wiki

~kautuk



Kautuk Sahni

View solution in original post

1 Reply

Avatar

Correct answer by
Administrator

check this:- How to enable log-rotation for the error.log

//

To reconfigure the error.log of CRX, simply edit the log4j.xml configuration file of the CRX webapp. This is located beneath the /WEB-INF folder of the deployed CRX webapp.

Please edit the section for the error appender and do the following:

  • change the class of the appender to org.apache.log4j.RollingFileAppender
  • add additional parameter maxBackupIndex to define the maximum number of rotated log-files to keep (default: 1 if missing)
  • optional: add parameter maxFileSize to limit the maximum file size of a rotated log-file (default: 10MB if missing)

Excerpt from log4j.xml

<appender name="error" class="org.apache.log4j.RollingFileAppender">

    <param name="maxBackupIndex" value="5" />

    <param name="File" value="crx-quickstart/logs/crx/error.log"/>

    <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>

    </layout>

</appender>

This change will take effect after a repository restart. For more information, please refer to [1].

[1]Log4jXmlFormat - Logging-log4j Wiki

~kautuk



Kautuk Sahni