logread
Read system log files
TLDR
Print the log
Print n messages
Filter messages by (Keyword/Regular Expression)
Print log messages as they happen
Display help
SYNOPSIS
logread
[options]
PARAMETERS
-f
Follow the log file; new entries will be printed as they are added. Similar to tail -f
.
-e string
Display only entries containing the specified string.
-n number
Show the last number lines of the log.
-l
Show the log in live mode with a small polling interval.
-s size
Limit the size of log read in bytes. Logs will be read from the end.
-d
Show debug messages. (If compiled with debug support)
DESCRIPTION
logread
is a command-line utility primarily used on embedded Linux systems, such as those running OpenWrt, to display the contents of the system log. It's a lightweight alternative to more feature-rich log analysis tools like syslog
or journalctl
found on larger distributions. logread
typically reads from /var/log/messages
(or other configured log file) and prints the log entries to standard output. It offers basic filtering capabilities, allowing users to display only the most recent entries, or entries matching specific keywords. This makes it invaluable for debugging and monitoring the behavior of embedded devices where resources are constrained. It's often included in busybox.
CAVEATS
logread
's functionality is basic compared to full-fledged system logging daemons. It lacks advanced features like log rotation, remote logging, and complex filtering rules. The exact options available and the default log file may vary slightly depending on the specific implementation (e.g., Busybox version).
EXIT STATUS
logread
typically exits with a status of 0 on success and a non-zero value on failure (e.g., if the log file cannot be accessed).
EXAMPLES
To display the last 100 log entries:logread -n 100
To follow the log file and display new entries containing 'error':logread -f -e error
To show the last 50 lines read backwards (using tail
as logread
alone doesn't provide this option):tail -n 50 /var/log/messages | tac
HISTORY
logread
's origins are tied to embedded Linux distributions, particularly OpenWrt, where its lightweight nature is advantageous. It was designed as a simple tool for viewing system logs on devices with limited resources. Its development closely follows the evolution of these distributions, with updates primarily focusing on bug fixes and compatibility improvements.
SEE ALSO
tail(1), grep(1), syslog(8), journalctl(1)