Log rotation in Jenkins means automatically deleting or archiving old build logs to save disk space and keep the system clean.
Click to reveal answer
beginner
How can you configure log rotation for a Jenkins job?
In the job configuration, under 'Discard Old Builds' or 'Build Discarder', you can set how many builds or days to keep logs before Jenkins deletes them.
Click to reveal answer
beginner
Why is log management important in Jenkins?
It prevents the server from running out of disk space and helps keep Jenkins fast and reliable by removing old unnecessary logs.
Click to reveal answer
intermediate
What Jenkins plugin can help with advanced log management?
The 'Log Parser Plugin' helps analyze and manage logs by highlighting errors and warnings in build logs.
Click to reveal answer
beginner
How does Jenkins decide which logs to delete during rotation?
Jenkins deletes logs based on the rules set in the job's 'Discard Old Builds' settings, like max number of builds or max days to keep.
Click to reveal answer
Where do you configure log rotation settings in a Jenkins job?
AUnder 'Build Discarder' in job configuration
BIn Jenkins global security settings
CIn the Jenkins system logs page
DIn the Jenkins user profile
✗ Incorrect
Log rotation is set per job under 'Build Discarder' to control how many builds and logs to keep.
What is the main benefit of log rotation in Jenkins?
ABacking up logs to cloud storage
BIncreasing build speed by caching logs
CImproving network security
DSaving disk space by removing old logs
✗ Incorrect
Log rotation helps save disk space by deleting old build logs automatically.
Which plugin helps highlight errors in Jenkins build logs?
ACredentials Plugin
BLog Parser Plugin
CPipeline Plugin
DGit Plugin
✗ Incorrect
The Log Parser Plugin analyzes logs and highlights errors and warnings.
If you want to keep only the last 10 builds' logs, where do you set this?
AIn the Jenkins system log file
BIn Jenkins global configuration
CIn 'Discard Old Builds' settings of the job
DIn the Jenkins user preferences
✗ Incorrect
You set the number of builds to keep in the 'Discard Old Builds' section of the job.
What happens if you do not configure log rotation in Jenkins?
AOld logs accumulate and may fill disk space
BJenkins deletes logs automatically after 7 days
CBuilds will fail due to missing logs
DLogs are sent to an external server
✗ Incorrect
Without log rotation, logs keep growing and can fill up disk space.
Explain how to set up log rotation for a Jenkins job and why it is important.
Think about cleaning old files to save space.
You got /5 concepts.
Describe the role of the Log Parser Plugin in Jenkins log management.
It’s like a highlighter for your logs.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of log rotation in Jenkins?
easy
A. To move old logs and save disk space
B. To delete all Jenkins jobs automatically
C. To increase Jenkins build speed
D. To backup Jenkins configuration files
Solution
Step 1: Understand what logs do in Jenkins
Logs record Jenkins activity and can grow large over time.
Step 2: Purpose of log rotation
Log rotation moves or archives old logs to save disk space and keep the system tidy.
Final Answer:
To move old logs and save disk space -> Option A
Quick Check:
Log rotation = save space [OK]
Hint: Log rotation helps keep disk space free by moving old logs [OK]
Common Mistakes:
Thinking log rotation deletes Jenkins jobs
Confusing log rotation with backup
Believing log rotation speeds up builds
2. Which of the following is the correct syntax to configure log rotation using copytruncate in a Linux logrotate config for Jenkins logs?
easy
A. /var/log/jenkins/jenkins.log {
truncatecopy
weekly
rotate 5
}
B. /var/log/jenkins/jenkins.log {
copytruncate
monthly
rotate seven
}
C. /var/log/jenkins/jenkins.log {
copytruncate
daily
rotate 7
}
D. /var/log/jenkins/jenkins.log {
copytruncate
daily
rotate seven
}
Solution
Step 1: Identify correct logrotate syntax
The copytruncate option is valid and used to copy then truncate the log file without stopping Jenkins.
Step 2: Check rotation frequency and count
Using daily and rotate 7 is correct syntax for daily rotation keeping 7 files.
Final Answer:
Correct syntax with copytruncate, daily rotation, and rotate 7 -> Option C
Quick Check:
copytruncate + daily + rotate 7 = correct [OK]
Hint: copytruncate keeps Jenkins running during log rotation [OK]
Common Mistakes:
Using 'truncatecopy' instead of 'copytruncate'
Writing 'rotate seven' instead of 'rotate 7'
Using invalid rotation frequency like 'monthly' with wrong number
3. Given this logrotate config snippet for Jenkins logs: