When enabling traffic logs by setting the artifactory.traffic.collectionActive=true in the artifactory.system properties file and restarting the service, those logs won't be compressed and moved to the archived directory like other log files. This can clutter the JFROG_HOME/artifactory/var/log directory and will consume extra disk space.
To change this behavior and enable log rotation where the v1 traffic logs are automatically compressed and moved to the archived directory, please follow these steps:
1. Backup the JFORG_HOME/artifactory/var/etc/artifactory/logback.xml file in case it will be required to revert the change at a later time.
2. Comment out the default appender block from the JFORG_HOME/artifactory/var/etc/artifactory/logback.xml file (Comments in XML start with "<! --" and end with "-->").
<!-- <appender name="TRAFFIC" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.dir}/artifactory-traffic</File> <encoder> <pattern>%m%n</pattern> </encoder> <rollingPolicy class="org.artifactory.traffic.policy.TrafficTimeBasedRollingPolicy"> <FileNamePattern>${log.dir.archived}/artifactory-traffic.%d{yyyyMMdd}</FileNamePattern> </rollingPolicy> </appender> -->
3. Add the custom appender.
<!-- custom traffic appender --> <appender name="TRAFFIC" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.dir}/artifactory-traffic.log</File> <rollingPolicy class="org.jfrog.common.logging.logback.rolling.FixedWindowWithDateRollingPolicy"> <FileNamePattern>${log.dir.archived}/artifactory-traffic.%i.log.gz</FileNamePattern> <compressLatest>true</compressLatest> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>25MB</MaxFileSize> </triggeringPolicy> <encoder> <pattern>%m%n</pattern> </encoder> </appender>
Once the custom appender is added, traffic logs will be forwarded to the artifactory-traffic.log file. The size-based trigger policy of 25 MB is applied and the logs will be compressed and moved to the JFROG_HOME/artifactory/var/log/archived directory based on the policy. To modify the size, it is possible to update the value of MaxFileSize. After compression, the logs will follow the structure artifactory-traffic.<TIMESTAMP>.log.gz.
No restart is required and the configuration change will automatically be picked up by the JVM. However, in the case of HA, it's important to make the change on each node in the cluster as the logback.xml file does not get propagated between the nodes.
Recommendations:
Artifactory Traffic log file record structure
How Can I Activate the Traffic Log?
Artifactory Traffic Log Analysis
Logging
Log Files Location and Naming
How to reduce the amount of tomcat logs in 7.x with logrotate
Configure the logback library
How to add the debug loggers in logback.xml file
Do changes in the logback.xml require a restart?