The printk writes in /var/log/messages
. So I was wondering if I could change this path from somewhere and get printk
to write in STDOUT or maybe a file. I searched but didn't find anything on the internet or man pages. Can anybody tell me if it is possible and how?
Asked
Active
Viewed 303 times
1

Natan Streppel
- 5,759
- 6
- 35
- 43

Imdad
- 683
- 1
- 9
- 27
-
1possible duplicate of [Where does printk print to?](http://stackoverflow.com/questions/4036624/where-does-printk-print-to) – Klaus Jun 24 '14 at 12:20
-
1It is in fact syslog that logs messages in `/var/log/`. Note that the kernel log message buffer is also exposed via `/dev/kmsg`, which you can read and print to stdout or a file. The kernel can't be responsible to pollute a process' standard output with kernel messages. – Michael Foukarakis Jun 24 '14 at 13:12
-
@Klaus No itsn't. That question has answers for "where printk write to?", my question is how to change the path where printk writes to! – Imdad Jun 24 '14 at 16:11
-
@MichaelFoukarakis so this mean that printk can be defined as "a funtion that writes in log"? – Imdad Jun 24 '14 at 16:14
-
Technical answer: no. You cannot change where printk writes to (without rewriting printk obviously). It goes to the kernel log message buffer as the link @Klaus provided showed. This is not a regular file that you can change. However, you can change the location where syslog moves the kernel messages later, via syslog.conf – Gil Hamilton Jun 27 '14 at 21:47
-
BTW, a given process' standard output [file descriptor #1] (assuming that is what you meant by "STDOUT") is not an option, since printk produces messages that are not in any way associated with the current process context (if there even is one). – Gil Hamilton Jun 27 '14 at 21:52
-
@Imbad: I believe your question is a duplicate, because you ask how to change where printk writes to. This is answered in the given link. You can only give exactly one place where printk messages go to. There is no way to provide a file per process or something else. All this is already answered in the given link. – Klaus Jun 28 '14 at 13:08