Skip to content

Add setting to disable file logging - #2570

Open
ahmershahdev wants to merge 2 commits into
borgbase:masterfrom
ahmershahdev:enable-file-logging-setting
Open

ahmershahdev wants to merge 2 commits into
borgbase:masterfrom
ahmershahdev:enable-file-logging-setting

Conversation

@ahmershahdev

Copy link
Copy Markdown
Contributor

Adds an “Enable logging to file” setting, enabled by default, so users can disable vorta.log and keep logging only to the console/journald.

Includes tests for toggling the setting and file handler behavior.

Tested on my fork before opening this: lint, mypy and the full test suite pass on Ubuntu and macOS (CI run). One of the new tests checks that no vorta.log is created while the setting is off.

Fixes #1705

Adds an 'Enable logging to file' checkbox (on by default) under a new Logging group in Settings. When it's off, the log file handler is removed, so logs only go to the console (e.g. journald when Vorta runs via systemd). The file handler is now created with delay=True, so no empty vorta.log is created if file logging is disabled.

Fixes borgbase#1705
@m3nu

m3nu commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thanks, this follows the approach discussed in the issue. Two things before merging:

  1. Background mode: init_logger(background=True) adds no console handler. With --daemonise/autostart and file logging off, Vorta logs nowhere, but the tooltip says logs go to the console. Please keep a console handler in background mode when file logging is disabled, or at least adjust the tooltip.
  2. Startup order: init_logger() runs before init_db(), so the setting is only applied at the end of init_db(). Anything logged before that, such as recovering interrupted jobs or migrations, still goes to vorta.log. Applying the setting right after init_db() in __main__.py, or reading it there before attaching the file handler, would close that gap.

…ting before init_db()

- In background mode, add a console handler while file logging is off, so logs are not lost.
- Read the setting from the database before the logger is set up, so nothing written while
  init_db() runs (job recovery, migrations) ends up in vorta.log when file logging is off.
@ahmershahdev

ahmershahdev commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for your feedback, I've fixed both points: in background mode, logs now go to the console when file logging is off, and the setting is now read before the file handler is attached, so nothing from init_db() ends up in vorta.log.

This branch has not been deployed

No deployments
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.

Disable logging to file in Settings

2 participants