Home

printk

Printk is the primary logging facility used by the Linux kernel to emit messages from kernel code. It formats messages and writes them to the kernel log buffer, and, depending on console configuration, to the system console as well. Unlike user-space I/O, printk runs in kernel space and uses the kernel’s own memory and synchronization mechanisms.

Usage of printk centers on log levels and formatting. Messages are produced by calling printk with an

Logging storage and viewing: printk messages are stored in the kernel log buffer and can be retrieved

Boot and runtime considerations: Early printk allows a minimal set of messages before the system console is

Printk remains a fundamental tool for kernel developers and for diagnosing issues, providing a standardized way

optional
log
level
prefix,
such
as
KERN_INFO
or
KERN_ERR,
for
example:
printk(KERN_INFO
"Device
ready:
%s\n",
devname);
In
modern
kernels,
common
wrappers
like
pr_info,
pr_err,
and
pr_debug
are
used,
which
call
printk
with
fixed
log
levels.
The
log
levels
range
from
emerg,
alert,
crit,
err,
warning,
notice,
info,
to
debug.
with
tools
like
dmesg
or
read
via
/proc/kmsg,
depending
on
configuration.
The
buffer
is
finite
and
subject
to
overflow;
when
full,
older
messages
may
be
dropped
or
overwritten.
The
amount
and
timing
of
visible
messages
depend
on
the
configured
loglevel
and
the
active
console(s).
available
during
boot.
The
printk
subsystem
supports
rate
limiting
and
dynamic
debugging
to
reduce
overhead
in
production.
Output
is
directed
through
the
kernel
console
subsystem,
which
may
be
serial,
VGA
text,
or
other
hardware,
depending
on
configuration.
to
report
status,
errors,
and
debug
information
from
kernel
code.