Skip to content

dantech2000/logx

Repository files navigation

logx

logx is an enhanced Kubernetes pod log viewer. It fetches pod logs, parses common structured and plain-text formats, highlights useful fields, and works as both a standalone CLI and a kubectl plugin.

Features

  • Smart log parsing for JSON and plain-text logs
  • Timestamp and log-level detection
  • Colorized, readable output
  • Multi-container pod support with interactive selection
  • Previous container logs with -p
  • Live log following with -f
  • Container listing with JSON, YAML, and POSIX output

Installation

Homebrew

brew tap dantech2000/tap
brew install --cask logx

The cask installs both logx and kubectl-logx. Because kubectl-logx is placed on your PATH, kubectl automatically discovers it as a plugin:

kubectl logx --help
kubectl plugin list

Release Binaries

Download the archive for your platform from the GitHub releases page, then place the binaries on your PATH:

  • logx for standalone use
  • kubectl-logx for kubectl logx

Kubernetes discovers the plugin form from the kubectl-logx executable name. No plugin registration is required.

Usage

Fetch logs from a pod:

logx my-pod -n my-namespace
kubectl logx my-pod -n my-namespace

The explicit subcommand form is also supported:

logx logs my-pod -n my-namespace

Options:

  • -n, --namespace: Kubernetes namespace, defaults to the current context namespace
  • --context: Kubernetes context, defaults to the current kubeconfig context
  • --kubeconfig: Path to a kubeconfig file, defaults to KUBECONFIG or ~/.kube/config
  • -c, --container: Container name for multi-container pods
  • -f, --follow: Follow log output
  • -l, --level: Filter logs by level: DEBUG, INFO, WARN, ERROR
  • -p, --previous: Fetch logs from the previous terminated container instance
  • --timeline: Show pod logs and Kubernetes events together sorted by time

Example:

logx my-pod -n my-namespace -c my-container -f -l INFO

Log Level Filters

-l, --level keeps logs at the selected level and above. For example, -l WARN shows WARN and ERROR entries while hiding DEBUG and INFO.

Plain text logs:

kubectl logx my-pod -n my-namespace -l WARN

Matches lines such as:

2026-05-15T00:38:03Z WARN upstream latency high
2026-05-15T00:38:04Z ERROR upstream unavailable

JSON logs:

kubectl logx api-pod -n my-namespace -l ERROR

Matches fields such as:

{"level":"error","ts":"2026-05-15T00:38:04Z","msg":"request failed","error":"timeout"}

Logfmt logs:

kubectl logx worker-pod -n my-namespace -l WARN

Matches fields such as:

time=2026-05-15T00:38:03Z level=warn component=worker msg="retry scheduled"
time=2026-05-15T00:38:04Z level=error component=worker msg="job failed"

Bracketed logs:

kubectl logx traefik-pod -n my-namespace -l WARN

Matches lines such as:

[2026-05-15 00:38:04] [WARN] [unknown] Traefik can reject some encoded characters in the request path
[2026-05-15 00:38:05] [ERROR] [unknown] Provider failed to sync providerName=kubernetes

Logs And Events Timeline

Use --timeline to view pod logs and Kubernetes events together in timestamp order:

kubectl logx my-pod -n my-namespace -c my-container --timeline -l WARN

Example output:

[2026-05-15 00:38:01] [EVENT] [Normal] Scheduled: Successfully assigned default/my-pod
[2026-05-15 00:38:03] [EVENT] [Warning] Unhealthy: Readiness probe failed
[2026-05-15 00:38:04] [LOG] [ERROR] request failed
[2026-05-15 00:38:05] [EVENT] [Warning] BackOff: Back-off restarting failed container

--timeline is intended for point-in-time troubleshooting and cannot be combined with --follow.

List containers in a pod:

logx containers my-pod -n my-namespace

Output formats:

logx containers my-pod -o json
logx containers my-pod -o yaml
logx containers my-pod -o posix

Version information:

logx version
logx version --short
logx version --output json
logx version --output yaml

Shell completion:

logx completion zsh > "${fpath[1]}/_logx"

Development

Prerequisites:

Use either asdf or Nix for a consistent toolchain.

With asdf:

asdf install

With Nix flakes:

nix develop

Manual prerequisites:

  • Go 1.26 or later
  • Access to a Kubernetes cluster for manual testing
  • kubectl configured with the appropriate context
  • just command runner

Build from source:

git clone https://github.com/dantech2000/logx.git
cd logx
just build

Common tasks:

just --list
just build
just test
just fmt

just build creates:

  • bin/logx
  • bin/kubectl-logx

Release

Create and push a version tag:

git tag -a vX.Y.Z -m "Release vX.Y.Z"
git push origin vX.Y.Z

The release pipeline publishes both the standalone logx binary and the kubectl-logx plugin binary. It also updates the Homebrew cask in dantech2000/homebrew-tap.

License

This project is licensed under the MIT License. See LICENSE.

About

Logx is a CLI tool to fetch and enhance Kubernetes pod logs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors