Limiting log size of jenkins.log or hudson.log

hudson, jenkins

Solution

You can use `logrotate`. You can find more information about `logrotate` on this kb article.

Here is how `logrotate` is configured on my system (`/etc/logrotate.d/jenkins`):

/var/log/jenkins/jenkins.log /var/log/jenkins/access_log {
    compress
    dateext
    maxage 365
    rotate 99
    size=+4096k
    notifempty
    missingok
    create 644
    postrotate
      if [ -s /var/run/jenkins.pid ]; then
        JPID=`cat /var/run/jenkins.pid`
        test -n "`find /proc/$JPID -maxdepth 0 -user jenkins 2>/dev/null`" && /bin/kill -s ALRM $JPID || :
      fi
    endscript
}

or if you don't really like signals, and it is crashing jenkins for you, you can use the logrotate definition from this debian config.

/var/log/jenkins/jenkins.log {
        weekly
        copytruncate
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
}

Problem

I use Hudson as well as Jenkins and I have several jobs on them. From time to time my hudson.log/jenkins.log file grows enormously. I am aware that the size of same can be limited. Please help in how to change and in what file the change has to be made.

Original source