"Macaron" logs required for minimal log configuration? #5515

Closed
opened 2025-11-02 06:27:24 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Zocker1999NET on GitHub (Jun 8, 2020).

Description

I want to minimize all logs to follow the GDPR and to save storage/bandwidth. For me, only warnings and errors including failed authentication attempts are important enough to be logged. To keep the failed authentication attempts I configured my general log level to INFO. To exclude other non-warning logs, I disabled Gitea's access logs and changed the router log level to "DEBUG". (see configuration below).

However Macaron still logs lines like [Macaron] [Static] Serving <path>. I could effectively disable Macaron logs, however I am not sure if Macaron can raise warnings and errors which would then go to /dev/null. I do not really know how Macaron works (especially how it is used in Gitea), so it would be glad if one core developer could explain, how important Macaron logs are, and add this explanation to the "Advanced: Logging Configuration" doc page.

[log]
ROOT_PATH =
MODE = console
BUFFER_LEN = 10000
REDIRECT_MACARON_LOG = true
MACARON = ,
ROUTER_LOG_LEVEL = Debug
ROUTER = ,
ENABLE_ACCESS_LOG = false
ACCESS = ,
ENABLE_XORM_LOG = true
XORM = ,

LEVEL = Info
STACKTRACE_LEVEL = Error

; Generic log modes
[log.x]
FLAGS = stdflags
EXPRESSION =
PREFIX =
COLORIZE = false

; For "console" mode only
[log.console]
FLAGS = level
LEVEL =
STDERR = false
COLORIZE = true

PS: I want Gitea to log everything to stdout because systemd can then insert this into its journal.

Originally created by @Zocker1999NET on GitHub (Jun 8, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.11.5 - Git version: 2.20.1 - Operating system: Debian Buster - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: https://gist.github.com/Zocker1999NET/a030eee7904347241749f655a92166e8 (examples for Macaron log messages) ## Description I want to minimize all logs to follow the GDPR and to save storage/bandwidth. For me, only warnings and errors including failed authentication attempts are important enough to be logged. To keep the failed authentication attempts I configured my general log level to INFO. To exclude other non-warning logs, I disabled Gitea's access logs and changed the router log level to "DEBUG". (see configuration below). However Macaron still logs lines like `[Macaron] [Static] Serving <path>`. I could effectively disable Macaron logs, however I am not sure if Macaron can raise warnings and errors which would then go to /dev/null. I do not really know how Macaron works (especially how it is used in Gitea), so it would be glad if one core developer could explain, how important Macaron logs are, and add this explanation to the "Advanced: Logging Configuration" doc page. ```ini [log] ROOT_PATH = MODE = console BUFFER_LEN = 10000 REDIRECT_MACARON_LOG = true MACARON = , ROUTER_LOG_LEVEL = Debug ROUTER = , ENABLE_ACCESS_LOG = false ACCESS = , ENABLE_XORM_LOG = true XORM = , LEVEL = Info STACKTRACE_LEVEL = Error ; Generic log modes [log.x] FLAGS = stdflags EXPRESSION = PREFIX = COLORIZE = false ; For "console" mode only [log.console] FLAGS = level LEVEL = STDERR = false COLORIZE = true ``` PS: I want Gitea to log everything to stdout because systemd can then insert this into its journal.
Author
Owner

@zeripath commented on GitHub (Jun 8, 2020):

In most configuration - less is more. Explicit is not better than implicit unless you absolutely understand everything you are setting.

  • As stated here: https://docs.gitea.io/en-us/logging-configuration/#the-router-logger you would be better off setting DISABLE_ROUTER_LOG=true. This will stop the [Static] Macaron logs appearing too.
  • Apart from these [Static] logs Macaron does very little logging - but it does log panics that reach its panic handler - so it probably is best not to send this to /dev/null.
  • ENABLE_ACCESS_LOG = false is the default so you do not need to set this.
  • ENABLE_XORM_LOG = true is the default so you do not need to set this.
  • Once you have disabled the ROUTER and ACCESS loggers you do not need to put ROUTER=, or ACCESS=, and in fact you should not because it will prevent you from getting appropriate logging in future should you wish to add these at a later date.
  • XORM=, is the default - but here it's fine to set this explicitly as you're actually logging this.
  • BUFFER_LEN=10000 is the default. You should not explicitly set it unless you have a good reason.
  • The [log.x] section does nothing as it is not connected to any logger.
  • The setting controlling logging of SQL commands is in the [database] section under LOG_SQL
  • Setting FLAGS=level is likely to significantly reduce the helpfulness of logging, consider adding back in medfile. Presumably you are relying on the timing being added by journalctl/syslog?
  • In general in the information provided by medfile has been been more useful for debugging than stacktraces which is why the default settings do not produce stacktraces (except as part of handling a panic) This is mostly because the error is often logged after it has been passed up the stack.
  • Are you aware of the EXPRESSION setting? You can use that to selectively log messages that match regexps?

Here's a substantially simplified logging that should do what you want:

[database]
...
LOG_SQL=false
...

[log]
DISABLE_ROUTER_LOG=true
REDIRECT_MACARON_LOG=true
MACARON=,
XORM=,
MODE=console
LEVEL=info
STACKTRACE_LEVEL=error
FLAGS=level
@zeripath commented on GitHub (Jun 8, 2020): In most configuration - less is more. Explicit is not better than implicit unless you absolutely understand everything you are setting. * As stated here: https://docs.gitea.io/en-us/logging-configuration/#the-router-logger you would be better off setting `DISABLE_ROUTER_LOG=true`. This will stop the `[Static]` Macaron logs appearing too. * Apart from these `[Static]` logs Macaron does very little logging - but it does log panics that reach its panic handler - so it probably is best not to send this to /dev/null. * `ENABLE_ACCESS_LOG = false` is the default so you do not need to set this. * `ENABLE_XORM_LOG = true` is the default so you do not need to set this. * Once you have disabled the ROUTER and ACCESS loggers you do not need to put `ROUTER=,` or `ACCESS=,` and in fact you should not because it will prevent you from getting appropriate logging in future should you wish to add these at a later date. * `XORM=,` is the default - but here it's fine to set this explicitly as you're actually logging this. * `BUFFER_LEN=10000` is the default. You should not explicitly set it unless you have a good reason. * The `[log.x]` section does nothing as it is not connected to any logger. * The setting controlling logging of SQL commands is in the `[database]` section under `LOG_SQL` * Setting `FLAGS=level` is likely to significantly reduce the helpfulness of logging, consider adding back in `medfile`. Presumably you are relying on the timing being added by journalctl/syslog? * In general in the information provided by `medfile` has been been more useful for debugging than stacktraces which is why the default settings do not produce stacktraces (except as part of handling a panic) This is mostly because the error is often logged after it has been passed up the stack. * Are you aware of the `EXPRESSION` setting? You can use that to selectively log messages that match regexps? Here's a substantially simplified logging that should do what you want: ```ini [database] ... LOG_SQL=false ... [log] DISABLE_ROUTER_LOG=true REDIRECT_MACARON_LOG=true MACARON=, XORM=, MODE=console LEVEL=info STACKTRACE_LEVEL=error FLAGS=level ```
Author
Owner

@Zocker1999NET commented on GitHub (Jun 8, 2020):

@zeripath Thank you for your answer.

  • Sorry, I did not see the option DISABLE_ROUTER_LOG. I searched for a option like this in the default configuration and in the Config Cheat Sheet, but only in the log sections. There the option is in the server section. But the option works in the log section like you used it. Was DISABLE_ROUTER_LOG recently moved?
  • After I tested my configuration above for a certain time, I discovered myself that the stacktraces seem not very helpful. Following your guide, I will add medfile back.
  • To configure Gitea, I copied the default configuration and adapted the parameters I wanted to change. The rest should still be the default values. To see all configuration parameters at once, I like to keep those in the config file even if I do not change them for now. But I see that some of Gitea's defaults may be adapted to other changes, so I will comment the default values in the future.
  • Yes, I rely on the timing added by systemd/journald. As systemd does catch the stdout and stderr of Gitea directly, there should no relevant latency.
  • No, I was not aware of EXPRESSION. I must have missed that too.
@Zocker1999NET commented on GitHub (Jun 8, 2020): @zeripath Thank you for your answer. - Sorry, I did not see the option `DISABLE_ROUTER_LOG`. I searched for a option like this in the default configuration and in the [Config Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/), but only in the `log` sections. There the option is in the `server` section. But the option works in the `log` section like you used it. Was `DISABLE_ROUTER_LOG` recently moved? - After I tested my configuration above for a certain time, I discovered myself that the stacktraces seem not very helpful. Following your guide, I will add `medfile` back. - To configure Gitea, I copied the default configuration and adapted the parameters I wanted to change. The rest should still be the default values. To see all configuration parameters at once, I like to keep those in the config file even if I do not change them for now. But I see that some of Gitea's defaults may be adapted to other changes, so I will comment the default values in the future. - Yes, I rely on the timing added by systemd/journald. As systemd does catch the stdout and stderr of Gitea directly, there should no relevant latency. - No, I was not aware of `EXPRESSION`. I must have missed that too.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5515