Bird
Raised Fist0
Jenkinsdevops~5 mins

Log management and rotation in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is log rotation in Jenkins?
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
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
Which plugin helps highlight errors in Jenkins build logs?
ACredentials Plugin
BLog Parser Plugin
CPipeline Plugin
DGit Plugin
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
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
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

      1. Step 1: Understand what logs do in Jenkins

        Logs record Jenkins activity and can grow large over time.
      2. Step 2: Purpose of log rotation

        Log rotation moves or archives old logs to save disk space and keep the system tidy.
      3. Final Answer:

        To move old logs and save disk space -> Option A
      4. 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

      1. Step 1: Identify correct logrotate syntax

        The copytruncate option is valid and used to copy then truncate the log file without stopping Jenkins.
      2. Step 2: Check rotation frequency and count

        Using daily and rotate 7 is correct syntax for daily rotation keeping 7 files.
      3. Final Answer:

        Correct syntax with copytruncate, daily rotation, and rotate 7 -> Option C
      4. 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:
      /var/log/jenkins/jenkins.log {
          copytruncate
          weekly
          rotate 4
      }
      What will happen after 5 weeks of running this rotation?
      medium
      A. Jenkins service will stop during log rotation
      B. All 5 weeks of logs are kept without deletion
      C. Logs are deleted every week without keeping any backups
      D. Only the latest 4 weekly logs are kept; older logs are deleted

      Solution

      1. Step 1: Understand rotate count meaning

        Rotate 4 means keep 4 old log files; older ones get deleted.
      2. Step 2: Apply to 5 weeks

        After 5 weeks, the oldest log (week 1) is deleted, keeping only weeks 2-5.
      3. Final Answer:

        Only the latest 4 weekly logs are kept; older logs are deleted -> Option D
      4. Quick Check:

        rotate 4 means keep 4 logs [OK]
      Hint: Rotate number = how many old logs to keep [OK]
      Common Mistakes:
      • Thinking all logs are kept forever
      • Assuming logs delete immediately without backups
      • Believing Jenkins stops during copytruncate rotation
      4. You configured Jenkins log rotation with copytruncate, but logs keep growing without rotation. What is the most likely cause?
      medium
      A. The Jenkins service is stopped
      B. The logrotate service is not running or not scheduled
      C. The copytruncate option is misspelled as copytrunc
      D. The log file path is incorrect in the config

      Solution

      1. Step 1: Check if logrotate runs

        If logrotate is not running or scheduled, logs won't rotate despite correct config.
      2. Step 2: Consider other causes

        Misspelling or wrong path cause errors, but usually logs won't grow if Jenkins stopped.
      3. Final Answer:

        The logrotate service is not running or not scheduled -> Option B
      4. Quick Check:

        Logrotate must run to rotate logs [OK]
      Hint: Ensure logrotate runs regularly to rotate logs [OK]
      Common Mistakes:
      • Assuming Jenkins must be stopped for rotation
      • Ignoring logrotate service status
      • Overlooking typos in config file
      5. You want to rotate Jenkins logs daily without stopping Jenkins and keep logs for 10 days. Which logrotate config snippet achieves this safely?
      hard
      A. /var/log/jenkins/jenkins.log { copytruncate daily rotate 10 missingok notifempty }
      B. /var/log/jenkins/jenkins.log { delaycompress weekly rotate 10 }
      C. /var/log/jenkins/jenkins.log { copytruncate monthly rotate 10 }
      D. /var/log/jenkins/jenkins.log { compress daily rotate 5 }

      Solution

      1. Step 1: Identify safe rotation without stopping Jenkins

        copytruncate copies and truncates logs safely without stopping Jenkins.
      2. Step 2: Check rotation frequency and retention

        Daily rotation with rotate 10 keeps 10 days of logs. missingok and notifempty handle missing or empty logs safely.
      3. Final Answer:

        Config with copytruncate, daily rotation, rotate 10, missingok, notifempty -> Option A
      4. Quick Check:

        copytruncate + daily + rotate 10 = safe rotation [OK]
      Hint: Use copytruncate for safe daily rotation without stopping Jenkins [OK]
      Common Mistakes:
      • Using monthly or weekly instead of daily rotation
      • Not using copytruncate causing Jenkins stop
      • Setting rotate less than 10 days
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard