Need to append current date to error.log file name | Community
Skip to main content
Level 2
July 12, 2017
Solved

Need to append current date to error.log file name

  • July 12, 2017
  • 1 reply
  • 3953 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

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

1 reply

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
July 13, 2017

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