Skip to content

Log system notices to text file #12902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
nodiscc opened this issue Sep 19, 2020 · 0 comments
Open
1 task done

Log system notices to text file #12902

nodiscc opened this issue Sep 19, 2020 · 0 comments
Labels
type/enhancement An improvement of existing functionality

Comments

@nodiscc
Copy link
Contributor

nodiscc commented Sep 19, 2020

  • Gitea version (or commit ref): 1.12.4
  • Can you reproduce the bug at https://try.gitea.io:
    • Not relevant

Description

It is a common practice to forward all application/daemon logs to a single location (local syslog, remote aggregator, SIEM...) for easier searching, analysis and alerting.

Currently system notices (failing to update a mirror, git operation error, internal crons...) are logged to the database and you can browse them at https://my.domain.org/admin/notices. It is impossible (hard?) to forward database logs to a log aggregation system using standard tools. For example I can easily forward gitea logs to syslog using this simple configuration file (https://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html), and be warned of errors using log monitoring/logwatch/graylog/lnav...:

# /etc/rsyslog.d/gitea.conf
# rsyslog - monitor gitea log files
module(load="imfile")

input(type="imfile"
      File="/var/lib/gitea/log/access.log"
      Tag="gitea:"
      Facility="daemon"
      PersistStateInterval="0")

input(type="imfile"
      File="/var/lib/gitea/log/gitea.log"
      Tag="gitea:"
      Facility="daemon"
      PersistStateInterval="0")

The local syslog daemon will pick up these log files, and add their messages to relevant outputs (/var/log/syslog, network forwarding...)

But this doesn't include notices. I have had a mirror failing for weeks without realizing it because I never browse /admin/notices manually. And more interesting errors to track down :)

This could also be useful for #8, you can simply log audit logs to file without having to implement syslog logging in gitea itself - just add an imfile watch on audit logs if you want it to go to syslog.

I think this should be logged to a separate log file notices.log or you can implement it the same way as other loggers with NOTICES = [console,file,conn,smtp,database] (https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini#L801)

@nodiscc nodiscc mentioned this issue Sep 19, 2020
@noerw noerw added the type/enhancement An improvement of existing functionality label Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants