How to use TimeBasedTriggeringPolicy for the Crowd Data Center Application Logs
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
TimeBasedTriggeringPolicy is a triggering policy provided by the Apache Log4j library that we can customize the log output based on the date and time as per our requirement.
Crowd doesn't fully support TimeBasedTriggeringPolicy yet. This is because it requires a date pattern in the file name. Please see our feature request CWD-6212 for more information. Feel free to use the below workaround in the meantime.
Environment
This has been tested on Crowd v5.2.3.
Solution
Ensure the Crowd service is stopped and take a backup of the installation directory if needed, just to be on the safe side.
Edit the below file:
1
/crowd-webapp/WEB-INF/classes/applicationContext-CrowdBootstrap.xml
Look for the parameter:
1
<property name="logFileName" value=
Update the parameter to the following and save the changes:
1
<property name="logFileName" value="atlassian-crowd.log.%d{yyyy-MM-dd-HH}"/>

Next, edit the file below:
1
/crowd-webapp/WEB-INF/classes/log4j2.properties
Look for the references to these properties:
1
2
appender.crowdlog.policies.size.type=SizeBasedTriggeringPolicy
appender.crowdlog.policies.size.size=20480KB
Replace the above lines with the changes below and save the file.
1
2
3
4
appender.crowdlog.policies.time.type=TimeBasedTriggeringPolicy
appender.crowdlog.policies.time.interval=1
appender.crowdlog.filePattern=${sys:crowd.home}/logs/crowd-%d{yyyy-MM-dd}.log
appender.crowdlog.policies.time.modulate=true
Finally, start Crowd and application should come up.


ℹ️ Note: appender.crowdlog.policies.time.interval=1 defines a number of hours, so if you want to rotate the logs every 1 hour, set the value to 1. Or as another example, if you want to rotate every 6 hours, then set the value to 6.
Was this helpful?