pygtail
Reads log file lines that have not been read.
What it is and what it does
Pygtail is a Python port of logcheck's logtail2 utility. It maintains an offset file to track which lines of a log file have already been read, then returns only the new lines on subsequent calls. It handles log rotation transparently, supporting both copytruncate-style rotation (where the file is copied then truncated) and inode-based rotation (where the file is moved and a new one created).
The package works both as a command-line tool and as a Python library. From the CLI, you point it at a log file and it prints unread lines; in code, you instantiate a Pygtail object and iterate over lines. It offers fine-grained control over when the offset is written back to disk, custom log rotation patterns, and options to read from the end of large files if the offset file is missing.
Use it for:
- Monitor application logs in real time by reading only new entries since the last check, avoiding re-processing old lines.
- Build log aggregation pipelines that track which lines have been shipped to a central system, using the offset file as a checkpoint.
- Process rotated logs without losing track of position across rotation boundaries, especially in high-volume logging scenarios.
- Implement custom log watchers that need fine-grained control over when offset state is persisted to disk.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pygtail reads only the new lines from a log file since the last read, tracking position with an offset file and handling log rotation automatically.
Yes, if you need incremental log reading with rotation support and can accept a copyleft license. The package is stable and has no known vulnerabilities, but maintenance is stalled since 2022; verify compatibility with your Python version and log rotation setup before relying on it for production use.
Install
pygtail on PyPI
pip
pip install pygtailuv
uv add pygtailpoetry
poetry add pygtailInstalling pygtail
Before you install
Low install friction with no runtime dependencies. Maintenance is aging—last release was 2022-11-06 and the repository shows no recent activity, though it remains unarchived with a final commit in 2025-09-04.
License in practice
Licensed under GPL v2 (copyleft). Any code that imports and uses pygtail must also be distributed under a compatible copyleft license; proprietary or permissive-licensed projects may face licensing conflicts.
Quickstart
from pygtail import Pygtail
for line in Pygtail("some.log"):
print(line, end='')
Verify before relying
- Whether the package works reliably with modern Python versions beyond those listed in classifiers (2.6, 2.7, 3.x unspecified).
- Current compatibility with contemporary log rotation schemes and whether the copytruncate and inode-based rotation modes remain effective.
Package facts
| License | GPL v2 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,377 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 225,547/month — #9,220 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pygtail-0.14.0-py3-none-any.whl
Keywords: logging, tail, logtail2
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
file-read-backwardsReads files line-by-line from end to beginning…
permissive · top 15,000 on PyPI
tailerTailer provides functions to read lines from…
permissive · top 15,000 on PyPI
concurrent-log-handlerProvides thread-safe and process-safe logging…
permissive · top 5,000 on PyPI
logzerologzero provides pre-configured Python logging…
permissive · top 5,000 on PyPI
logtail-pythonA Python client library for sending structured…
permissive · top 5,000 on PyPI
loguruLoguru provides a pre-configured logger that…
permissive · top 1,000 on PyPI
segyioSegyio reads and writes SEG-Y formatted seismic…
copyleft · top 15,000 on PyPI
aiofileProvides asynchronous file I/O operations for…
permissive · top 1,000 on PyPI
pdfminerExtracts text and layout information from PDF…
permissive · top 15,000 on PyPI
mootdxReads market data from Tongdaxin (a Chinese…
permissive · top 15,000 on PyPI