Skip to content

Write STDERR logs to stderr - #2701

Merged
acockburn merged 1 commit into
AppDaemon:devfrom
tmilnthorp:fix-stderr-log-stream
Nov 6, 2026
Merged

acockburn merged 1 commit into
AppDaemon:devfrom
tmilnthorp:fix-stderr-log-stream

Conversation

@tmilnthorp

@tmilnthorp tmilnthorp commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2699.

A log configured with filename: STDERR built its StreamHandler on sys.stdout, so it ended up on stdout. That includes the default error_log, which the docs already say goes to stderr. This switches the handler to sys.stderr.

Behaviour change worth calling out: with the default config, error_log output now actually reaches stderr. Anyone redirecting only stdout (e.g. appdaemon > ad.log) will no longer see error-log lines in that file. That's what the docs describe, but it isn't what happened before.

Tests: tests/unit/test_logging_streams.py configures one STDOUT and one STDERR log and checks each line lands on the right stream. It fails on dev and passes with the fix.

To test Logging without touching the shared AppDaemon/Error loggers, I added a make_logging fixture to tests/unit/conftest.py. It builds a fresh Logging outside the singleton with uniquely named loggers and detaches their handlers afterwards. Two other logging PRs I'm opening (JSON output, syslog level prefix) add the identical fixture, so they merge cleanly in any order.

A log configured with `filename: STDERR` (the default for error_log) built
its StreamHandler on sys.stdout, so it was indistinguishable from STDOUT.

Fixes AppDaemon#2699
@acockburn
acockburn merged commit 33c5a85 into AppDaemon:dev Nov 6, 2026
9 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.

Logs configured with filename: STDERR are written to stdout

2 participants