tailer is a CLI for watching a directory of log files by pattern.
It behaves like tail -f, but it also keeps rescanning the directory and starts following new matching files as they appear. This is useful for log directories where new files are dropped over time.
Build and install from this repository:
go install ./cmd/tailerInstall a tagged release directly:
go install github.com/mariusvniekerk/tailer/cmd/tailer@latestThe binary will be installed to GOBIN if it is set. Otherwise Go installs it to $(go env GOPATH)/bin.
For example:
$(go env GOPATH)/bin/tailertailer --dir <directory> --pattern <glob>Example:
tailer --dir /var/log/myapp --pattern "*.log"This will:
- Find existing files in
/var/log/myappmatching*.log - Start following appended lines in those files
- Detect new
*.logfiles in that directory - Start following those new files automatically
- Prefix each output line with the source file path
-dir string
Directory to watch for matching files. (default ".")
-from-start
Start existing files from byte 0 instead of the end.
-pattern string
Glob pattern for files inside the watched directory. (default "*.log")
-poll-interval duration
How often to rescan the directory for new files. (default 1s)
Each emitted line is prefixed with the full path of the source file:
/var/log/myapp/app.log: request complete
/var/log/myapp/worker.log: job queued
Tail all log files in the current directory:
tailer --pattern "*.log"Read existing files from the beginning instead of starting at EOF:
tailer --dir ./logs --pattern "*.log" --from-startUse faster directory rescans for rapidly created files:
tailer --dir ./logs --pattern "*.log" --poll-interval 250msWatch rotated or recreated files:
tailer --dir ./logs --pattern "app-*.log"tailer uses github.com/nxadm/tail for low-level tail-follow behavior, including reopen support.
The CLI itself is built with Cobra.
The current implementation:
- Watches one directory, not recursive subdirectories
- Uses glob matching against filenames in that directory
- Starts existing files at EOF by default
- Starts newly discovered files from the beginning
- Stops cleanly on
Ctrl-C
Run tests:
go test ./...Build the binary:
go build ./...