Jenkins在Linux的日志管理实践
一 日志位置与查看方式
常见路径与实时查看
Web界面日志
二 日志轮转与清理
使用 logrotate 进行系统级轮转(推荐)
/var/log/jenkins/*.log {
daily
rotate 7
compress
missingok
notifempty
create 0644 root adm
sharedscripts
postrotate
if [ -f /var/run/jenkins/jenkins.pid ]; then
kill -HUP $(cat /var/run/jenkins/jenkins.pid)
fi
endscript
}
构建日志的保留策略
logRotator(daysToKeepStr: '30', numToKeepStr: '100')
清理与监控
0 0 * * * find /var/log/jenkins/ -type f -name "*.log" -mtime +7 -delete
三 集中式日志与调试
集中式日志平台
调试与自定义日志
-Djava.util.logging.config.file=/path/logging.properties