One command to find, search, follow, and watch local logs.
logc is a read-only Linux command-line tool for operators who still want to inspect logs themselves, but do not want to repeatedly assemble find, grep, zgrep, journalctl, and tail -F pipelines.
logc api 'timeout|reset' --since 30m -f| Before | After |
|---|---|
find + grep + zgrep + tail -F + journalctl |
logc |
View the landing page · Browse the source · Report an issue
Important
Homebrew packaging is still being worked on. brew install logc is not available yet; use the source installation below.
During an incident, the first problem is often not understanding the error—it is finding the right log source quickly.
logc focuses on local log aggregation and operator-driven debugging:
- discovers recent application logs across common Linux paths;
- follows several files as one live stream, including newly created and rotated files;
- searches current, rotated, and gzip-compressed logs;
- resolves services by name, PID, or listening port;
- groups sources by application, module, system, network, database, or custom configuration;
- highlights
FATAL,ERROR,WARN,INFO, andDEBUGin terminals; - exposes systemd and Docker logs without replacing their native tools;
- provides a live error-rate and repeated-error view with
logc watch.
It intentionally stays local and transparent. It does not upload logs, run AI analysis, or replace a centralized observability platform.
Requires Go 1.22 or newer.
Install directly with Go:
go install github.com/debugc-clis/logc@latestOr build from a checkout:
git clone https://github.com/debugc-clis/logc.git
cd logc
make build
sudo install -m 0755 ./bin/logc /usr/local/bin/logc
logc versionFor a user-local installation:
mkdir -p ~/.local/bin
install -m 0755 ./bin/logc ~/.local/bin/logc
export PATH="$HOME/.local/bin:$PATH"# Not available yet
brew install logcThe Homebrew formula and tap are on the roadmap. Do not use this command as the current installation method.
# Discover recent logs, print their latest lines, then keep following
logc
# Follow sources matching a service, path, PID, or port
logc api
logc /opt/log/payment
logc 1234
logc :8080
# Search recent API logs
logc api ERROR --since 30m
# Search first, then continue following matching sources
logc api 'timeout|reset' --since 30m -f
# Watch live error rate and repeated messages
logc watch ERRORPlain logc is a follow command: it prints the latest 10 lines from up to 20 recently modified files, then refreshes as those files receive new content. It also rescans periodically so newly created matching log files can join the stream.
Stop any follow or watch command with Ctrl+C.
In Bash 3.2 or newer, enable completion for the current shell:
source <(logc completion bash)Tab completes static commands, subcommands and relevant flags, with normal shell filename completion for targets, including paths with spaces. For future interactive Bash sessions, add that line to the Bash startup file you use; logc does not edit shell configuration automatically.
Generating the script does not load logc configuration or discover logs. Tab handling uses shell built-ins rather than running logc, Docker or source discovery; normal filename completion still inspects the local directory. Dynamic source groups, modules, containers, processes and ports are not enumerated. Zsh/fish completion is not implemented yet.
completion is now a reserved first-word command. To address a target with
that name, use logc ./completion or logc -- completion instead.
- Configuration section mistakes fail early: unknown nonempty headers such as
[grop.api]now report the configuration path and line instead of silently treating following settings as global. Use[group.api]for a source, not[api]. - Empty time windows fail early: an explicit
--since ''returns exit code 2 instead of silently behaving as if the option were omitted. This also catches empty shell variables in file, watch and system commands; Docker keeps its native argument handling. - Explicit searches validate every source: with a nonempty
-m/--matchexpression, unresolved positional selectors fail before searching or following instead of silently searching only the valid subset. - Optional Bash completion:
logc completion bashprints a Bash 3.2-compatible script for command and flag completion, without starting log discovery or external services. - Safer large context requests: file searches grow before-context storage only as rows are read, rather than reserving the entire requested
-Cwindow up front. Snapshot context bounds also avoid integer overflow that could hide matching rows. - Search failures are visible to scripts: file searches return exit code 1 if any selected file cannot be fully read, while preserving readable results from every attempted source. An incomplete initial search does not silently start live follow.
- Bounded search output: dense file and gzip searches emit results in bounded batches instead of retaining every selected line until the file ends. Context order and duplicate counts are preserved across batches.
- Correct Docker source labels: JSON output keeps the container name as its source and module even when Docker options follow the container, such as
logc docker api --tail 100 --follow=false --json. - Predictable recent windows: relative
--sincevalues must be positive and fit a Go duration. Invalid day/week windows now fail with an explicit error instead of silently hiding logs or selecting unexpected history. - Stable classification for overlapping groups: when several configured groups match a file, the first matching group in case-sensitive alphabetical name order supplies its category and module. Classification no longer depends on map iteration order.
- Source filters get their own discovery slots: default discovery applies
--categoryand--modulebefore selecting files. Busy unrelated services no longer consume the file limit for a filtered stream, recent search, or watch view. - Search-follow keeps discovering files: directory, quoted glob, and configured-group targets retain their discovery scope after the initial search. Newly created matching active files can join on the next rescan; explicit single-file targets stay limited to that file.
- More reliable log rotation: plain
logcandlogc watchdrain unread data from the old file before switching to its replacement, including backlogs larger than 4 MiB. This applies to sources followed with an open file descriptor. - Complete counts on normal journal completion: systemd watch processes already-read, buffered events before rendering its final view when the journal command completes normally.
- External-stream error handling: oversized lines in Docker, system, and systemd watch streams now stop the log-reading subprocess and return an error instead of hanging. This stops the local reader, not the container or service.
- Distribution-aware system logs: when journald is unavailable on Linux,
logc systemcan follow traditional system-log files selected for the detected distribution. Override these withsystem_login~/.logc.conf. - Scriptable source inspection:
logc ls --jsonandlogc where TARGET --jsonexpose source metadata and logrotate status for other tools.
Try these workflows:
# Aggregate live application logs, following file replacement and truncation
logc
# Watch repeated API errors while logs rotate
logc watch ERROR api --since 30m
# Follow Docker errors with logc filtering and duplicate suppression
logc docker --tail 100 -m ERROR --dedup api
# Export discovered sources and resolved file paths
logc ls --json
logc where api --json| Goal | Command |
|---|---|
| See what is happening on the machine now | logc |
| Focus the default live stream on database logs | logc --category database |
| Follow one application or module | logc api |
| Search recent matching logs | logc api ERROR --since 30m |
| Search and continue following | `logc api 'timeout |
| Inspect a process by PID | logc 1234 |
| Inspect the process listening on a port | logc :8080 |
| Watch repeated failures and error rate | logc watch ERROR |
| Stream systemd journal entries | logc system api -f |
| Follow a Docker container | logc docker --tail 100 -f api |
| List discovered log sources | logc ls |
| Explain why a target matched | logc where api |
logcThe default command:
- scans configured roots such as
/var/log,/opt/var/log, and/opt/log; - skips known system-log paths that are better handled by
logc system; - selects recently modified application logs;
- prints a small tail from each source;
- keeps following updates like a multi-file
tail -F; - detects truncation, replacement, and common logrotate activity;
- periodically discovers newly created matching files.
Target a service, path, process, or port to narrow the stream:
logc payment
logc /srv/payment/log
logc 1234
logc :8080If you know the type of service but not its log paths, filter default discovery:
logc --category database
logc ERROR --category database --since 30m
logc watch ERROR --category databaseCategory and module filters are applied before the default file-selection limit, including recent historical searches and follow/watch rescans. For example, with max_files=2, two eligible database logs can be selected even when many unrelated application logs are newer. Existing recency, exclusion, and file-count limits still apply. Use --module NAME for a configured source module; category and module filters can be combined.
The second positional argument is a Go regular expression:
logc api ERROR
logc api 'timeout|connection reset'
logc nginx ' 5[0-9][0-9] 'For an unambiguous search across several sources, provide the expression with
-m (or --match):
logc /srv/api/app.log /srv/worker/worker.log -m ERROR --since 30mWith a nonempty explicit expression, all positional arguments are source
selectors. If one cannot be resolved, logc exits 1 before printing search rows
or starting follow; it does not silently search only the valid subset. For
example, adding an invalid selector such as :99999 fails even if the first
file is valid. Underlying empty-group and unmatched-glob resolution rules are
unchanged, but a token they leave unconsumed now fails the whole explicit search.
This is source-selector validation, not a guarantee that every source has logs.
The implicit logc api ERROR form still works as before.
Searches include active logs, rotated files such as .1, and gzip files such as .2.gz. By default, candidates are limited to recently modified files.
logc api ERROR --since 30m
logc api ERROR --since 2026-08-08T13:00:00Z
logc api ERROR --allRelative --since windows must be positive and representable (at least 1 ns and
less than roughly 292 years). Fractional days and weeks work: 0.5d means
12 hours and 1.5w means 10.5 days. Zero, negative, nonfinite and overflowing
windows are rejected with exit code 2; use --since 1d, not --since -1d.
An explicitly empty value (--since '', including an empty shell variable) is
also rejected before searching or following. Check that WINDOW is set before
running logc api ERROR --since "$WINDOW"; omitting --since still uses the
normal defaults. An empty occurrence cannot be hidden by a later valid value.
today, local dates (2026-08-08), quoted local date-times
("2026-08-08 13:00:00") and RFC3339 timestamps remain supported. These rules
apply to file search, watch and system logs; logc docker --since is forwarded
to Docker and follows Docker's own syntax.
Useful output controls:
logc api ERROR -C 2
logc api ERROR --dedup
logc api ERROR --category app --module api
logc api ERROR --jsonLarge searches can emit several blocks for the same file, including with JSON:
logc api ERROR --all --jsonEach block holds at most 256 output rows or 1 MiB of undecorated line text
(including context separators and duplicate-count suffixes). One accepted line
larger than 1 MiB occupies its own block. JSON escaping and metadata add overhead;
these are output-buffer limits, not a limit on total matches or context memory.
Concatenate each block's lines array in output order to retain the selected
sequence. Duplicate runs still collapse across batch boundaries.
Small searches retain the N matches suffix. For a multi-block file, earlier
blocks say search continues and the last says N matches total, counting
direct matches before context and deduplication. If reading fails, already
selected results remain visible; the final nonempty block says
N matches before read error and stderr reports the cause. Such counts cover
only the readable prefix. File searches return 0 when all selected files
are searched without a read failure (including zero matches), and 1 when
any selected file cannot be fully read. Other selected files are still attempted,
and their matches are retained. Invalid CLI arguments remain exit code 2.
The status contract is the same for terminal and JSON output; diagnostics stay
on stderr. Unlike grep, a successful search with no matches is not a failure.
When piping output through another command in Bash or zsh, use
set -o pipefail if the pipeline must retain logc's nonzero status.
Add -f to search historical candidates first and then follow active files:
logc api 'timeout|reset' --since 30m -fThis is useful when you need immediate context before waiting for the next occurrence.
If any file fails during the initial search, logc finishes attempting the other selected files, reports the incomplete search and exits 1 without starting live follow. If only rotated/compressed history is damaged, explicitly skip that history and retry against the active directory or source:
logc /srv/api/log ERROR --current -f--current skips history; it does not repair files or bypass errors in active
logs. The historical bootstrap of the traditional system-file fallback also
stops before following if its search fails. Plain follow, watch, Docker and
native journal streams keep their existing behavior.
To keep watching a log directory across deployments that create new filenames:
logc /srv/api/log ERROR --since 30m -f
logc '/srv/api/log/*.log' ERROR --since 30m -fDirectory, glob, and configured-group targets keep their original selectors during follow. New matching active files join on a rescan (scan_interval=5s by default), and subsequent matching lines appear in the stream. Rotated and gzip logs are searched for initial context but are not added as live sources. At least one active file must exist when follow starts. An explicit target such as /srv/api/log/app.log follows only that file and its replacement, not other filenames in the directory.
logc watch ERROR
logc watch 'timeout|connection reset' api
logc watch ERROR '/opt/log/*.log,/etc/service.log'The watch view reports:
- current error rate;
- total and repeated-event counts;
- first and last occurrence times;
- grouped normalized messages;
- source category, module, and logrotate status.
Path arguments may be files, directories, glob patterns, or comma-separated selectors. The dashboard refreshes every second and calculates its live rate over a one-minute window.
logc watch ERROR --since 30m
logc watch ERROR api --full
logc watch ERROR --category app --module apilogc watch is a terminal dashboard and intentionally does not support --json or --all.
logc system
logc system api
logc system api --since 30m -f
logc system api -n 200On systemd machines, logc system uses journalctl. Distribution-specific file paths remain configurable for systems that use traditional log files.
logc docker api
logc docker --tail 100 -f api
logc docker --since 30m --timestamps api
logc docker --details apilogc docker [docker logs options] CONTAINER preserves Docker's logging behavior while keeping the command under the same logc workflow. The container name or ID is passed directly to docker logs.
Docker logs can also use logc's filtering, context, deduplication, colors, and JSON output:
logc docker --since 30m -m ERROR -C 2 api
logc docker --tail 100 -m ERROR --dedup --json apiDocker options can also follow the container name or ID:
logc docker api --tail 100 --follow=false --jsonThis prints the last 100 available lines without following. Each JSON block
identifies path as docker:api, category as container, and module as
api, rather than mistaking an option value for the container. Docker arguments
are forwarded in their original order; Docker still validates its native options.
Follow mode is enabled by default. A container name or ID is required; logc docker -- reports a usage error rather than starting a stream.
logc ls
logc ls --json
logc where api
logc where :8080 --jsonlogc lslists discoverable sources with category, module, recency, and logrotate metadata.logc where TARGETexplains matched paths and source resolution without following them.
| Option | Purpose |
|---|---|
-f, --follow |
Continue following after the initial output |
-n N, --lines N |
Set initial lines per file |
--since VALUE |
Limit search by duration or timestamp |
--all |
Disable the recent-file search cutoff |
-C N, --context N |
Show context lines around matches |
--dedup |
Collapse repeated search results |
--category NAME |
Filter by source category |
--module NAME |
Filter by module |
-i, --ignore-case |
Match without case sensitivity |
--current |
Skip rotated and gzip history |
--json |
Emit machine-readable output where supported |
--no-color |
Disable terminal colors |
--full |
Do not truncate long rows in logc watch |
-m REGEX, --match REGEX |
Provide the match expression explicitly |
--exclude PATTERN |
Add a path exclusion for this run |
Run logc --help or logc COMMAND --help for the authoritative option list.
The user configuration file is ~/.logc.conf.
Create a starter configuration:
logc config initPrint the effective merged configuration:
logc config showdefault_log_dir=/var/log
default_log_dir=/opt/var/log
default_log_dir=/opt/log
system_log=/var/log/syslog
system_log=/var/log/messages
lines=10
max_files=20
recent=24h
flush_interval=500ms
scan_interval=5s
max_batch_lines=10
max_buffer_lines=2000
color=true
ignore_line=.*GET /health.*
ignore_line=.*GET /metrics.*
[group.api]
path=/srv/api/log/*.log
path=/opt/log/api/*.log
category=app
module=apiCustom source sections use [group.NAME]; unknown nonempty sections such as
[api], [global], [default] or a misspelled [grop.api] are rejected at
the header with the configuration path and line number. Previously those
headers silently switched to global settings; correct them before upgrading.
Use [group.api] for a source. For global settings, remove [global] / [default]
and put the keys before the groups, or use the existing empty header [] to
leave a group. [] (also [ ]) does not delete groups or restore defaults.
Flat group.NAME=PATH entries and global keys inside valid group sections
remain supported. This change does not add bare-name group aliases.
When a file matches multiple configured groups, logc checks group names in ascending, case-sensitive alphabetical order. The first matching group supplies the file's category and module. Configuration order and pattern specificity do not change that precedence. This applies to the effective merged configuration, including built-in groups; inspect it with logc config show.
[group.api]
path=/srv/api/log/*.log
category=app
module=api
[group.platform]
path=/srv/*/log/*.log
category=system
module=platformIn this example, /srv/api/log/app.log matches both groups and consistently receives category=app and module=api, because api sorts before platform. Uppercase names sort before lowercase names. Inspect the classification of an existing file with:
logc where /srv/api/log/app.log --jsonThis rule governs file metadata and category/module filters. An explicit group selector such as logc platform still resolves that group's own paths, and logc ls still lists each configured group's settings.
| Setting | Default | Meaning |
|---|---|---|
default_log_dir |
common Linux log roots | Directories scanned for logs |
system_log |
distribution defaults | Traditional system logs used when journald is unavailable |
lines |
10 |
Initial lines shown per file |
max_files |
20 |
Maximum files selected |
recent |
24h |
Recent-file discovery window |
flush_interval |
500ms |
Maximum wait before buffered lines are printed |
scan_interval |
5s |
Follow-mode discovery interval |
max_batch_lines |
10 |
Live file-follow rows emitted per source per flush; search batches use the separate fixed limits described above |
max_buffer_lines |
2000 |
Maximum pending lines retained per source |
color |
true |
Enable terminal colors when stdout is a TTY |
ignore_line |
none | Regular expressions omitted from output |
exclude |
distribution defaults | Discovery exclusions |
group.NAME |
none | Custom source selectors |
Built-in discovery includes common application, web-server, and database locations, including MySQL and MariaDB log paths. User configuration is merged after defaults, so search roots, exclusions, line filters, and source groups can be extended or overridden.
logc recognizes commonly used debugging logs across Debian, Ubuntu, CentOS, RHEL, Fedora, Amazon Linux, Alpine, Arch, and related distributions. It keeps general messages, kernel, authentication, security, and firewall logs out of normal application discovery, then uses the correct traditional files as a logc system fallback when journald is unavailable. User-session, cron, and installer noise are not included in the default system source set.
Use logc system for system logs. Override the detected file set with system_log=! followed by one or more system_log=/custom/path entries when the machine uses a custom layout.
When a discovered file is covered by a readable logrotate configuration, logc marks it as rotated-managed in list, location, normal, watch, and JSON output. The follower also detects file replacement and truncation so rotation does not permanently detach the stream.
Because logrotate configuration may include unreadable files or shell-expanded rules, detection is best effort and never required for reading a log.
- Read-only:
logcdoes not modify log files or services. - Permissions: it only reads paths available to the current user.
- Bounded discovery: the default recent window and file limit prevent accidental full-disk scans.
- Safe roots: recursive discovery refuses filesystem-root scans.
- Long-running follow: active files are polled and discovery is refreshed without retaining full log history in memory.
- Search buffers: selected search results are emitted in bounded batches; scanner buffers, requested before-context, duplicate state and output encoding use additional memory.
- Context memory: file searches retain before-context lazily and only for regex searches. A large
-Con a small file does not reserve space for unseen rows, but context memory still grows with actual retained lines and their sizes; this is not a new global memory limit or a context cap. Large snapshot windows keep all available eligible context without overflowing their bounds. - Rotation handling: truncation and inode replacement reopen the active source; rotated and gzip files remain searchable.
- Copytruncate limits: when polling observes a file shrink, follow/watch reset partial-line state so old fragments are not joined to new entries. If a file is truncated and grows back to the previous read offset or beyond between polls, that truncation may not be detected; unread data removed by truncation cannot be recovered.
- Rotation backlog: normal follow and
watchdrain the old file in bounded reads before switching to its replacement, including backlogs larger than 4 MiB. - Open-file control: follow mode limits active descriptors and falls back to polling where needed.
- Terminal safety: untrusted control characters are sanitized before terminal rendering.
- Backpressure: a slow output consumer can delay refreshes because stdout and stderr writes remain synchronous.
- External streams: Docker, system, and systemd watch streams reject individual lines larger than 2 MiB, stop the producer, and report an error instead of waiting indefinitely.
- Stopping a stream:
Ctrl+CorSIGTERMends logc's stream and waits for its immediate local log-reading subprocess to be reaped. Containers and system services keep running. Output writes remain synchronous, so cancellation does not interrupt an indefinitely blocked stdout/stderr write. - JSON mode: paths and message text are preserved for downstream tools.
logc where api
logc api 'timeout|reset' --since 30m -C 2
logc api 'timeout|reset' --since 30m -flogc watch ERROR api --since 30mlogc api ERROR --since 30m
logc system api --since 30m
logc docker --since 30m api- Discover, classify, and follow recent local logs.
- Search active, rotated, and gzip-compressed files.
- Resolve targets by name, path, PID, and listening port.
- Filter by time, category, module, context, and deduplication.
- Stream systemd journal and Docker container logs.
- Watch error rate, repeated events, and occurrence times.
- Detect common logrotate coverage and follow rotated files.
- Emit colored terminal output and structured JSON.
- Load defaults plus user-defined source groups from
~/.logc.conf. - Generate optional Bash command/flag completion with native filename fallback.
- Publish and maintain Homebrew distribution so
brew install logcbecomes available. - Publish and validate tagged binary releases for supported platforms.
- Expand distribution-specific discovery fixtures and integration tests.
- Improve source ranking for very large hosts.
- Extend completion to other shells and add manual pages.
Contributions are welcome.
- Fork debugc-clis/logc.
- Create a focused branch.
- Add tests for behavior changes.
- Run
go test ./.... - Open a pull request describing the operational problem and the chosen behavior.
Please keep logc local-first, read-only, scriptable, and predictable.
The project follows a recurring PM, Staff Go engineering, and independent review workflow. Each cycle prioritizes concrete SRE scenarios, implements and tests focused changes, and updates this README and relevant landing-page examples before publishing. See the iteration playbook and iteration log and backlog for the process, verified work, and next priorities. Planned items are not advertised as shipped features.
Parts of this project and its documentation may be generated or assisted by AI. AI-assisted changes should be reviewed and tested by maintainers and contributors before release.
This software is provided without warranty. To the maximum extent permitted by law, the author and contributors are not liable for data loss, service interruption, lost profits, operational impact, or other direct or indirect damages resulting from installation, configuration, or use. Users remain responsible for validating the tool in their own environments.
