---
source: https://iinventedlight.com/library/notes/python-logging-handlers.md
title: "Python logging.handlers: send log records to streams and files"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, logging.handlers — Logging handlers; CPython, logging.handlers documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-logging-handlers"
tags: [python, logging, handlers, StreamHandler, FileHandler]
client: Librarian
sources:
  - id: S1
    title: "logging.handlers — Logging handlers"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/logging.handlers.html
    accessed: 2026-11-24
    license: "PSF License Version 2"
  - id: S2
    title: "logging.handlers documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/logging.handlers.rst
    accessed: 2026-11-24
    license: "PSF License Version 2"
---
# Python logging.handlers: send log records to streams and files
**Answer:** The following useful handlers are provided in this package.

## What is included

StreamHandler, FileHandler, and NullHandler are defined in the logging module itself, but documented here along with the other handlers.

StreamHandler sends logging output to streams such as sys.stdout, sys.stderr, or any object that supports write() and flush().

If stream is specified, the instance will use it for logging output.

Any file-like object that supports write() and flush() can be the stream.

## How a file handler writes

FileHandler inherits the output functionality from StreamHandler.

If mode is not specified, 'a' is used.

The specified file is opened and used as the stream for logging.

The record is then written to the stream followed by terminator.

If you do not specify a stream, sys.stderr will be used.

## See also

- [python-logging-basics](https://iinventedlight.com/library/notes/python-logging-basics/)
- [python-warnings](https://iinventedlight.com/library/notes/python-warnings/)
- [python-io](https://iinventedlight.com/library/notes/python-io/)

## Claims

- id: C1
  claim: The following useful handlers are provided in this package.
  source: S1
  evidence: "The following useful handlers are provided in the package."

- id: C2
  claim: If you omit the stream, sys.stderr will be used.
  source: S1
  evidence: "otherwise, sys.stderr will be used"

- id: C3
  claim: If mode is not specified, 'a' is used.
  source: S1
  evidence: "If mode is not specified, 'a' is used"

- id: C4
  claim: If a stream is given, StreamHandler uses it for output.
  source: S2
  evidence: "If *stream* is specified, the instance will use it for logging output"

## Sources

- [S1] logging.handlers — Logging handlers. Python Software Foundation. https://docs.python.org/3/library/logging.handlers.html . License: PSF License Version 2. Accessed 2026-11-24.

- [S2] logging.handlers documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/logging.handlers.rst . License: PSF License Version 2. Accessed 2026-11-24.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, logging.handlers — Logging handlers; CPython, logging.handlers documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
