views:

77

answers:

4

Hello guys,

Just a quick question on printk function at the kernel level, if i call this where will the message be printed to.(im using ubuntu on i386 arch with the latest kernel downlaod)

cant find it anywhere,

if someone could also point me in the right direction for some sort of manual for the printk function it would be great!

+1  A: 

The printk(9) man page has a very small bit of information on it. In short, it gets sent to the log buffer, where a syslog daemon can pick it up and handle it. It also gets sent to the console if its loglevel is high enough (see dmesg(1) for that bit).

Ignacio Vazquez-Abrams
+4  A: 

printk messages go to the kernel log message buffer, which can be exposed in a variety of ways depending on system configuration. The shell command dmesg will show them, and they should also be being copied to files in /var/log by the syslog daemon. It's possible to get them logged to a serial console or a text-mode virtual terminal, but I don't remember how offhand.

Zack
found it in the syslog , thank you
molleman
+2  A: 

dmesg should display printk messages.

Alan Haggai Alavi
+1  A: 

If you have put some printk() statements in the kernel module to debug and trying to capture the outputs as they are printk'ed, what you are looking for is klogd. Perform a man klogd for more detains and options.

Here's a wrapper script for klogd that I coded a while back to ease some quick debugging pain:

#!/bin/bash

function bashtrap()
{
        echo
        echo -n "[+] stopping klogd ... "
        pids=`ps aux | grep klogd | awk '{print $2}'`

        for pid in $pids
        do    
                kill SIGTERM $pid 2> /dev/null

        done
        echo "done"

        if [ $1 ]
        then
                exit;
        fi  
}

sync
bashtrap

klogd -x -f - -n -c 8 2>&1 1 | tee klog.txt & klog_pid=$!;

echo "[+] klogd started"
echo "[+] press ctrl+c to exit ... $klog_pid"

sync
trap "bashtrap 1" SIGINT

while [ 1 ]
do
        sleep 3
        echo -n "."
done

ps aux | grep klogd
Babil