mkunit logs
View logs from a unit.
mkunit logs <name> [flags]
Description
The logs command displays logs from a unit via journalctl. It provides
a convenient interface for common log viewing operations without needing to remember
journalctl flags.
Arguments
| Argument | Description |
|---|---|
<name> |
Name of the unit (with or without extension) |
Flags
| Flag | Description | journalctl equivalent |
|---|---|---|
--follow, -f |
Follow log output in real-time | -f |
--lines <n>, -n |
Number of lines to show | -n |
--since <time> |
Show logs since this time | --since |
--until <time> |
Show logs until this time | --until |
--boot, -b |
Show logs from current boot only | -b |
--priority <level>, -p |
Filter by priority (emerg, alert, crit, err, warning, notice, info, debug) | -p |
--grep <pattern>, -g |
Filter logs by pattern | --grep |
--output <format>, -o |
Output format (short, json, cat, verbose) | -o |
--no-pager |
Don't use a pager | --no-pager |
--system |
View logs for a system unit | --system |
Time Formats
The --since and --until flags accept various time formats:
today,yesterday1 hour ago,30 minutes ago2024-01-15,2024-01-15 10:30:00-1h,-30m,-1d
Examples
View recent logs
mkunit logs myapp
Follow logs in real-time
mkunit logs myapp -f
Show last 100 lines
mkunit logs myapp -n 100
Logs from the last hour
mkunit logs myapp --since "1 hour ago"
Logs from today only
mkunit logs myapp --since today
Filter by priority (errors and above)
mkunit logs myapp -p err
Search for a pattern
mkunit logs myapp --grep "error\|failed"
JSON output for parsing
mkunit logs myapp -o json --no-pager | jq '.MESSAGE'
Logs between specific times
mkunit logs myapp --since "2024-01-15 10:00" --until "2024-01-15 12:00"
System service logs
mkunit logs nginx --system -f
See Also
- mkunit status - Check unit status
- mkunit show - Show unit configuration
man journalctl- Full journalctl documentation