Manage the console.log rotation:

ARTIFACTORY: How to manage the Console Log?

AuthorFullName__c
Elina Floim
articleNumber
000005203
FirstPublishedDate
2022-01-23T13:55:59Z
lastModifiedDate
2025-05-15
VersionNumber
8
By setting the log file max size and the number of files in the system.yaml file. For instance, this example sets the max size to 50MB and the max number of files to 50:
shared:
  logging:
    rotation:
      maxSizeMb: 50
      maxFiles: 50
      compress: true
The log rotation is configured by default to run every hour using a cron job. The configured cron expression can be viewed by executing the following command in the Artifactory server:
root@elinaf-art-7126:/opt/jfrog/artifactory/var/log# crontab -l -u artifactory
The response should look similar to this:
55 * * * * /opt/jfrog/artifactory/app/third-party/logrotate/logrotate /opt/jfrog/artifactory/var/etc/logrotate/logrotate.conf --state /opt/jfrog/artifactory/var/etc/logrotate/logrotate-state
This cron indicates that the logrotate job runs at minute .55 of every hour.
In case the cron job is not being executed, for any reason, it can be manually triggered using the following command:
su -s "/bin/sh" artifactory -c "/opt/jfrog/artifactory/app/third-party/logrotate/logrotate -v /opt/jfrog/artifactory/var/etc/logrotate/logrotate.conf --state /opt/jfrog/artifactory/var/etc/logrotate/logrotate-state"
Note: in some cases, it may be required to grant logrotate executable permissions:
chmod +x /opt/jfrog/artifactory/app/third-party/logrotate/logrotate
*paths should be changed according to the Artifactory installation
The output should be similar to this, depending on the state of the rotation:
reading config file /opt/jfrog/artifactory/var/etc/logrotate/logrotate.conf
olddir is now archived
extension is now .log
warning: 'size' overrides previously specified 'daily'
Reading state from file: /opt/jfrog/artifactory/var/etc/logrotate/logrotate-state
Allocating hash table for state file, size 64 entries
Creating new state

Handling 1 logs

rotating pattern: /opt/jfrog/artifactory/var/log/console.log  26214400 bytes (10 rotations)
olddir is archived, empty log files are not rotated, old logs are removed
considering log /opt/jfrog/artifactory/var/log/console.log
  Now: 2022-01-11 13:46
  Last rotated at 2021-12-09 14:55
  log does not need rotating (log size is below the 'size' threshold)
The cron expression can be modified by following these steps:
1. Switching to the Artifactory user:
su artifactory
2. Running the following command to modify the crontab artifactory job:
crontab -e
3. Modifying the cron part of the expression to the desired value. For instance, * * * * * (which is “every minute”) and saving.

After any of the above modifications, Artifactory should be restarted for the changes to take effect. 

Note:
1) changing the crontab job might require a restart of the machine for the changes to take effect. 
2) Log rotation is not available in the following installations - Archive, Mac/Windows, and Manual Docker Compose (which don't use the bundled script). For Kubernetes installations, the console.log is disabled by default and it is strongly recommended to keep it that way (for the aforementioned installations as well). 

Note:
In some cases the log rotation won't work. You can check the /var/log/cron.log for errors like the below:

1) If you see an error like the below in /var/log/cron.log:

crond[19020]: (artifactory) FAILED to authorize user with PAM (Permission denied)

crontab[32486]: (artifactory) AUTH (crontab command not allowed)

You may need to add the following in /etc/cron.allow and /etc/security/access.conf:

cat /etc/cron.allow

artifactory

grep artifactory /etc/security/access.conf

+ : artifactory : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6

2) If you see the below error in /var/log/cron.log:

crond[23163]: (artifactory) PAM ERROR (Authentication token expired)

You’ll need to make the password for the artifactory user never expiring. You can do so with "chage artifactory". Confirm the settings with:

chage -l artifactory

Last password change : Oct 20, 2022

Password expires : never

Password inactive : never

Account expires : never

Minimum number of days between password change : -1

Maximum number of days between password change : -1

Number of days of warning before password expires : -1