Jenkins logs are stored in the $JENKINS_HOME directory, typically at /var/lib/jenkins/logs on Linux or C:\Program Files\Jenkins\logs on Windows. The most critical file is jenkins.log, which captures the main server startup and error events. A common misconception is that build output lives here; it does not. Build logs are generated dynamically for each job run and stored separately.
Understanding this separation is vital for troubleshooting. If your Jenkins instance fails to start, you look in the home directory logs. If a specific pipeline step fails, you look in the job-specific workspace or log directories. Confusing these two locations leads to wasted time searching for error messages that simply do not exist where you expect them.
What Is $JENKINS_HOME?
The environment variable $JENKINS_HOME (or system property jenkins.home) defines the root directory where Jenkins stores all persistent data. This includes configuration files, plugin data, credentials, and crucially, the log files. By default, if you install Jenkins as a service on Linux using the package manager, the home directory is set to /var/lib/jenkins. On Windows, the default installation path usually places the home directory inside the program files folder, often C:\Program Files (x86)\Jenkins.
You can verify the exact location of your $JENKINS_HOME by checking the Jenkins web interface. Navigate to Manage Jenkins > System Information. Look for the entry labeled "Jenkins home". This value is absolute and overrides any default assumptions. If you have configured a custom home directory during setup, all log paths below will be relative to that custom root.
Key Log Files Explained
Inside the logs subdirectory of your Jenkins home, several distinct files serve different diagnostic purposes. You need to know which one to open based on the problem you are facing.
- jenkins.log: This is the primary log file. It records the lifecycle of the Jenkins controller itself. Startup sequences, shutdown events, plugin loading errors, and general Java exceptions appear here. If Jenkins crashes on boot, this is your first stop. It rotates daily, meaning older logs are compressed into
jenkins.log.YYYY-MM-DD.gz. - jenkins.err.log: This file captures standard error output from the Java process running Jenkins. While
jenkins.loghandles structured logging,jenkins.err.logcatches raw stack traces and unhandled exceptions that might bypass the normal logging framework. It is smaller but contains high-severity crash data. - console.log: This file shows the console output of the Jenkins process as it starts up. It is useful for diagnosing port conflicts or permission issues that occur before the web interface becomes available. It is generally only relevant during initial deployment or restarts.
- audit.log: If the Audit Trail plugin is installed, this file records user actions such as configuration changes, job creations, and deletions. It is essential for security compliance and tracking who changed what setting.
Log Rotation and Disk Space
Jenkins uses a rolling file appender by default. When jenkins.log reaches a certain size or crosses midnight, it is archived. The archive naming convention follows the date format YYYY-MM-DD. These archived files are gzip-compressed to save disk space. However, if you have a long-running instance without cleanup, these archives can consume significant storage. You should monitor the size of the logs directory periodically.
Where Build Logs Are Stored
This is the area where most users get confused. Build logs are not stored in the global logs directory. Instead, they are tied to individual jobs and builds. Each job has its own directory under the jobs folder within $JENKINS_HOME.
The structure looks like this: $JENKINS_HOME/jobs/. For example, if you have a job named "web-deploy" and you ran build number 42, the log file would be located at /var/lib/jenkins/jobs/web-deploy/builds/42/log on Linux. This file contains the entire console output of that specific execution, including stdout and stderr from shell commands, Maven output, or Gradle tasks.
If you need to analyze a historical build failure, you must navigate to this specific path. Do not search the global jenkins.log file for build-specific errors unless the error caused the Jenkins process itself to fail. Build failures are isolated to the job directory.
Docker and Containerized Installations
If you are running Jenkins in a Docker container, the file paths differ because the container has its own filesystem. The default Docker image maps the Jenkins home directory to /var/jenkins_home. Therefore, the logs are stored at /var/jenkins_home/logs inside the container.
To access these logs from your host machine, you typically use the docker logs command rather than navigating the filesystem directly. Running docker logs -f <container_id> streams the jenkins.log content to your terminal. If you need to inspect specific build logs, you must either exec into the container (docker exec -it <container_id> /bin/bash) or ensure your Jenkins home directory is mounted as a volume on the host. If you mount a volume, the logs will persist on your host at the mapped path, allowing you to read them with standard text editors.
How to Check Logs via the Web UI
You do not always need command-line access to view logs. Jenkins provides built-in interfaces for both global and build logs.
To view the global jenkins.log, go to Manage Jenkins > System Log. This page displays the last few thousand lines of the current log file. It allows you to filter by log level (INFO, WARNING, SEVERE). This is the safest way to check for startup errors without risking file permission issues.
To view a build log, navigate to the specific job, click on the build number in the build history, and select Console Output. This renders the contents of the log file in the browser. Note that very large build logs may take time to load in the browser due to HTML rendering overhead. For massive logs exceeding 100MB, using the command line or SSH to tail the file is faster.
Troubleshooting Common Access Issues
When trying to read these files, you may encounter permission denied errors. On Linux systems, Jenkins typically runs as the user jenkins or www-data. If you are logged in as root or another user, you cannot read the files directly without elevated privileges. Use sudo cat /var/lib/jenkins/logs/jenkins.log to view the content. Be cautious when editing these files directly; modifying jenkins.log while Jenkins is running can corrupt the log state or cause the application to lose track of its write position.
On Windows, permissions are managed through NTFS ACLs. The Jenkins service usually runs under a local system account or a dedicated service account. If you try to open the logs folder with a standard user account, you may lack read access. Right-click the folder, select Properties, and check the Security tab to ensure your user account has Read & Execute permissions. If you installed Jenkins manually as a user process rather than a service, the logs will be in your user profile directory, specifically %APPDATA%\Jenkins or similar, depending on how you launched the executable.
Configuring Custom Log Paths
In rare cases, you may need to store logs on a different disk, perhaps because the system partition is small. You can change the log directory by modifying the Java arguments passed to Jenkins. Add the argument -Djava.util.logging.config.file=/path/to/custom/logging.properties to your startup script. This requires creating a custom logging.properties file that points the handlers to your desired directory. This is an advanced configuration and should be tested thoroughly in a non-production environment first. Incorrect configuration here can prevent Jenkins from starting entirely.