在CentOS环境下管理GitLab日志的技巧主要包括以下几个方面:
gitlab-ctl
命令:
sudo gitlab-ctl tail
gitlab-rails
:sudo gitlab-ctl tail gitlab-rails
nginx/gitlab_error.log
:sudo gitlab-ctl tail nginx/gitlab_error.log
sudo cat /var/log/gitlab/gitlab-rails/production.log
或 less /var/log/gitlab/gitlab-rails/production.log
tail -f /var/log/gitlab/gitlab-rails/production.log
。gitlab.rb
配置文件:
logging['logrotate_frequency'] = "daily" # 每天切割一次日志
logging['logrotate_rotate'] = 30 # 日志文件保留30天
logging['logrotate_compress'] = "compress" # 使用压缩
gitlab-ctl reconfigure
使配置生效。。logrotate
:
logrotate
管理,可以设置日志文件的大小和保留期限。/etc/gitlab/gitlab.rb
文件中的 logrotate
配置来自定义日志轮换规则。/var/log/gitlab/gitlab-rails/*.log {
daily rotate 7
compress
missingok
notifempty
create 0644 gitlab gitlab
}
sudo logrotate -f /etc/gitlab/gitlab.rb
强制重新旋转日志。。通过以上技巧,可以有效地管理 CentOS 上 GitLab 的日志,确保系统的稳定性和可维护性。