Jenkins : Access Logging

Steps to enable an access log

For Ubuntu:

  1. Add these lines to /etc/default/jenkins above JENKINS_ARGS:
    # Enable access log
    JENKINS_ACCESSLOG="--accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access.log"
    
  2. Edit /etc/default/jenkins and add  $JENKINS_ACCESSLOG to JENKINS_ARGS
  3. Enable log rotation: edit /etc/logrotate.d/jenkins and change /var/log/jenkins/jenkins.log to /var/log/jenkins/*.log

For Windows service:

  1. Add the line to %JENKINS_HOME%/jenkins.xml in <arguments> block.
     --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file="%BASE%/logs/access.log"
    
  2. Restart Jenkins service after edit.
    Updated jenkins.xml
    <service>
      <id>jenkins</id>
      <name>Jenkins</name>
      <description>This service runs Jenkins continuous integration system.</description>
      <env name="JENKINS_HOME" value="%BASE%"/>
      <!--
        if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
        The following value assumes that you have java in your PATH.
      -->
      <executable>%JAVA_HOME%\bin\java</executable>
    
      <arguments>-Xrs -Xmx3072m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war" --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file="%BASE%/logs/access.log"</arguments>
    
      <!--
        interactive flag causes the empty black Java window to be displayed.
        I'm still debugging this.
      <interactive />
      -->
      <logmode>rotate</logmode>
    
      <onfailure action="restart" />
    </service>
    
  3. Access logs will be created in "%BASE%/logs/access.log" but (warning) log will be lost on service restart.