Apart from the plethora of tools and plugins which are supported by Jenkins, it provides an incredibly powerful logger that keeps track of almost every operation on the server.
Jenkins allows us to view and examine the logs for every build including the error messages, script outputs, command execution processes, and more.
As developers, you may encounter some instances where you need to review the system logs and examine what operations are executed and where lies the potential problems.
In this tutorial, we will learn the various ways to access our system’s Jenkins logs. In addition, this tutorial demonstrates how to view the logs on a Linux system based on Debian 11.
NOTE: By default, running the Jenkins.war file manually using the java -jar command outputs the log information to the standard output. Hence, the log may not be available in the location of the stored log.
Where Are Logs Stored in Jenkins?
The easiest way to access the Jenkins logs from the terminal is simply locating where the files are stored in the filesystem.
It is good to keep in mind that the location of the Jenkins logs may vary depending on the target system and the configuration.
However, by default, the following are the locations of the Jenkins logs in various systems:
- Linux Systems – /var/log
- Windows – %JENKINS_HOME%. The JENKINS_HOME is the location where Jenkins is installed on the target system.
- MacOS – /var/log/jenkins/
Jenkins also allows us to customize the location of the log directory by editing the Jenkins configuration file.
On the Linux systems, you can find the Jenkins configuration file in the following directory:
On the Red-Hat-based systems, the Jenkins configuration file is located in the following:
On macOS, you can find the Jenkins configuration file in the following:
On Windows, the Jenkins configuration file is located in the following:
Method 1: How to View the Jenkins Logs
The first method that you can use to view a Jenkins server’s logs is the cat command followed by the log file.
For example, to view the Jenkins logs in Linux, we can use the following command:
You will find two log files on Windows:
- Jenkins.out – This holds the general log information on the Jenkins server.
- Jenkins.err – This log file stores the error logs from the Jenkins server.
Method 2: How to View the Jenkins Logs
We can also view the logs on a Jenkins server from the Jenkins dashboard.
Start by logging into your Jenkins web interface -> Manage Jenkins -> System Log.
Select “All Jenkins Logs” to view the system logs on the server.
You will see the log information on the server as shown in the following sample output:
To view the log as an RSS feed, you can navigate to your Jenkin_url/manage/log/rss.
Example:
http://localhost:8080/manage/log/rss
Conclusion
This tutorial taught you how to view the Jenkins logs on various systems. You can explore our other tutorials to learn how you can configure multiple Jenkins log levels.