How to stop Jenkins log from becoming huge?

后端 未结 6 350
花落未央
花落未央 2020-12-07 17:47

Recently my jenkins.log has started getting very large, very quickly, full of exceptions about DNS resolution. I attempted to use logrotate, but the log file grows too quick

相关标签:
6条回答
  • 2020-12-07 18:12

    Modify JAVA_ARGS in /etc/default/jenkins (location for Debian / Ubuntu installations at least) to disable DNS multicast feature.

    Change this: JAVA_ARGS="-Djava.awt.headless=true"

    To this: JAVA_ARGS="-Djava.awt.headless=true -Dhudson.DNSMultiCast.disabled=true"

    And restart the service service jenkins restart

    0 讨论(0)
  • 2020-12-07 18:19

    For the ones using Centos/Redhat, the option to disable the DNS Multicast feature can found in /etc/sysconfig/jenkins

    JENKINS_JAVA_OPTIONS="-Dhudson.DNSMultiCast.disabled=true -Dhudson.udp=-1 -Djava.awt.headless=true"
    
    0 讨论(0)
  • 2020-12-07 18:22

    You can disable the logging of these DNS errors by adjusting the logging settings within Jenkins.

    From the Jenkins web interface go to:

     Manage Jenkins -> System Log -> Log Levels (on the left)
    

    Add the following entry:

    Name: javax.jmdns
    
    Level: off
    

    This way you can keep the Multicast DNS feature but without all the logging data.

    0 讨论(0)
  • 2020-12-07 18:28

    You can plug in on Jenkins initialization with init.groovy file in Jenkins home folder and change the logging levels permanently with it. The changes will be kept even if Jenkins is restarted. There is a simple content of the file:

    import java.util.logging.Level
    import java.util.logging.Logger
    
    Logger.getLogger("").setLevel(Level.SEVERE)
    Logger.getLogger("org.apache.sshd").setLevel(Level.SEVERE)
    Logger.getLogger("winstone").setLevel(Level.SEVERE)
    

    You can change the name of the logger and the level so that it suits your needs. See my article on this topic for more details.

    0 讨论(0)
  • 2020-12-07 18:32

    In my case I received the log entry whenever a Sign in attempt was rejected via the user interface.

    User authentication is done via LDAP and the provided user/password tuple is correct. After a while the sign in attempt is working.

    Is it possible that the user is rejected because of the enabled DNS Multi cast feature?

    0 讨论(0)
  • 2020-12-07 18:35

    This seems to be due to DNS multicast as explained here: https://issues.jenkins-ci.org/browse/JENKINS-25369

    Workaround: add -Dhudson.DNSMultiCast.disabled=true to JAVA_ARGS.

    PS: I'm answering my own question here on Stack Overflow because I couldn't find the answer on Google easily, and it will be useful to other people running Jenkins.

    0 讨论(0)
提交回复
热议问题