Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Need to append current date to error.log file name

phalgunk3688591
Level 2
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
kautuk_sahni
Correct answer by
Community Manager
Community Manager

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

View solution in original post

1 Reply
kautuk_sahni
Correct answer by
Community Manager
Community Manager

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

View solution in original post