I was debugging my syscall and I found that dmesg prints so many lines which made me couldn't see all of my printk
.
我正在调试我的syscall,我发现dmesg打印了很多行,这使我看不到所有的printk。
Is it possible to printk
to a file?
是否有可能对文件进行打印?
2 个解决方案
#1
0
Use trace_printk()
instead of printk()
使用trace_printk()而不是printk()
And your prints should be in ftrace buffers.
你的指纹应该在ftrace缓冲区中。
$ cd /sys/kernel/debug/tracing
$ cat trace
Refer http://june-takeout.blogspot.dk/2010/01/debugging-kernel-using-ftrace-part-1.html and see section "Using trace_printk()"
请参阅http://june-takeout.blogspot.dk/2010/01/debugging-kernel-using-ftrace-part-1。请参阅“使用trace_printk()”一节
#2
0
The major difference between printk() and printf() is the capability of the former to specify a loglevel. The kernel uses the loglevel to decide whether to print the message to the console. The kernel displays all messages with a loglevel below a specified value on the console.
printk()和printf()之间的主要区别在于前者能够指定一个日志级别。内核使用loglevel来决定是否将消息打印到控制台。内核在控制台中以低于指定值的日志级别显示所有消息。
On a standard Linux system, messages from the log buffer go through syslogd to /var/log/messages.
在一个标准的Linux系统中,来自日志缓冲区的消息通过syslogd传递到/var/log/ messages.net
Otherwise you could check your syslogd configuration to see where they go.
否则,您可以检查您的syslogd配置,以查看它们的去向。
If you don't have syslogd at all and have systemd it's possible you could find your messages with journalctl -k -f
如果您没有syslogd,并且有systemd,那么您可以通过journalctl -k -f找到您的消息。
#1
0
Use trace_printk()
instead of printk()
使用trace_printk()而不是printk()
And your prints should be in ftrace buffers.
你的指纹应该在ftrace缓冲区中。
$ cd /sys/kernel/debug/tracing
$ cat trace
Refer http://june-takeout.blogspot.dk/2010/01/debugging-kernel-using-ftrace-part-1.html and see section "Using trace_printk()"
请参阅http://june-takeout.blogspot.dk/2010/01/debugging-kernel-using-ftrace-part-1。请参阅“使用trace_printk()”一节
#2
0
The major difference between printk() and printf() is the capability of the former to specify a loglevel. The kernel uses the loglevel to decide whether to print the message to the console. The kernel displays all messages with a loglevel below a specified value on the console.
printk()和printf()之间的主要区别在于前者能够指定一个日志级别。内核使用loglevel来决定是否将消息打印到控制台。内核在控制台中以低于指定值的日志级别显示所有消息。
On a standard Linux system, messages from the log buffer go through syslogd to /var/log/messages.
在一个标准的Linux系统中,来自日志缓冲区的消息通过syslogd传递到/var/log/ messages.net
Otherwise you could check your syslogd configuration to see where they go.
否则,您可以检查您的syslogd配置,以查看它们的去向。
If you don't have syslogd at all and have systemd it's possible you could find your messages with journalctl -k -f
如果您没有syslogd,并且有systemd,那么您可以通过journalctl -k -f找到您的消息。