Skip to content

Conversation

@Xe
Copy link
Contributor

@Xe Xe commented Nov 20, 2025

Closes #1125

When I designed Anubis' logging subsystem details, I did it with the experience of a recovering former SRE under the axiom of "you pay for log storage (cheap) or you pay for extended outages (expensive)". Most of the environments I run Anubis in have a rotating 10 megabyte log window with minimal retention.

Apparently this causes issues when used in normal distributions with normal distribution packaging. journald has issues handling Anubis' fairly moderate amount of logging and there's been numerous comments about this.

I concede that maybe an alternate approach is required here. The horrible part is that changing the default logging level isn't really an option because that would break automation.

This PR adds the ability to write logs to the filesystem instead of standard error. In order to configure this, add a logging block to your policy file like this:

logging:
  sink: file
  parameters:
    file: "./var/anubis.log"
    maxBackups: 3 # keep at least 3 old copies
    maxBytes: 67108864 # each file can have up to 64 Mi of logs
    maxAge: 7 # rotate files out every n days
    compress: true
    useLocalTime: false # timezone for rotated files is UTC

This makes Anubis log everything to ./var/anubis.log until the log file is either 7 days old or 64Mi big. When a file gets too big, it gets compressed with gzip and renamed to the date it was rotated out.

Additionally, you can also set the log level in the policy file:

logging:
  sink: stdio
  level: warn

The format of level is what is allowed by slog.Level in the Go standard library. Typical values include:

Log level Use in Anubis
debug The raw unfiltered torrent of doom. Only use this if you are actively working on Anubis or have very good reasons to use it.
info The default logging level, fairly verbose in order to make it easier for automation to parse.
warn A "more silent" logging level. Much less verbose. Some things that are now at the info level need to be moved up to the warn level in future patches.
error Only log error messages.

These are also the same levels accepted by --slog-level and SLOG_LEVEL.

Once this is merged, #991 needs to be fixed up and amended.

Checklist:

  • Add documentation for this feature
  • Add documentation about Anubis' logging verbosity and how to change it
  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Added test cases to the relevant parts of the codebase
  • Add smoke test that actually makes sure logs are written to the log file
  • Ran integration tests npm run test:integration (unsupported on Windows, please use WSL)
  • All of my commits have verified signatures

Xe added 3 commits November 19, 2025 16:00
Ref #864

You were right @kotx, it is a bad idea to set the global logger
instance.

Signed-off-by: Xe Iaso <[email protected]>
@Xe Xe self-assigned this Nov 20, 2025
Xe added 2 commits November 21, 2025 11:30
Assisted-by: GLM 4.6 via Claude Code
Signed-off-by: Xe Iaso <[email protected]>
@Xe Xe merged commit f032d5d into main Nov 21, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Do not log IP address

3 participants