Link to home
Start Free TrialLog in
Avatar of Volga
Volga

asked on

How to use klogd properly?

I am new to Linux and I have a hard time making klogd work properly to display debug messages.
I'm writing Linux driver modules using insmod and rmmod. I have kprint output debug messages but I need to figure out how to have klogd display the debug messages.

It looks like klogd was already initialized during the boot up process (I'm using Ubuntu). So when I entered:
$ klogd -c 8
It says klogd is already running. The question is what do I need to do to prevent klogd from being initialized. And if there is any way to reintialize klogd to a higher level (8) so I can see the debug messages.
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Do you mean printk?
You can probably just let klogd run - it intercepts kernel messages and sends them to the syslog subsystem. You might want to tune your /etc/syslog.conf to put kernel messages somewhere convenient to you.
Avatar of Volga
Volga

ASKER

Duncan:

Yes I mean printk. What I actually want to see are the messages displaying interactively. I would prefer to see those debug messages in the same window after I type the command insmod...
I remember I was able to do that when we were developing driver modules for an embedded Linux device. With the embedded device we were able to customize the environment, I wonder how to do that on a desktop.
The -c argument to klogd affects what goes to the *console*. That is not the same as your current X window - if not running X then it is the VC1. X has/had xconsole which seems to have stopped working for me. Perhaps you can tell syslogd to rout kernel messages to somewhere helpful (like one of your xterms - you'd have to reconfigure syslogd after you knew the pty number)
Avatar of Volga

ASKER

Duncan:

I think I'm confused again with all these Linux terms. What I really mean is the console, just like a DOS window or DOS box  in the Windows world.
I'm new to Linux, so please can you let me know how do I configure syslogd, where is it located, and how do I find out the pty number of that console (or box, or window, whatever it is called).
All I want to see are debug messages right after I type the command insmod... in the same console box.

ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Volga

ASKER

Duncan:
Apparently this works for me. But I just wonder why we couldn't use klogd -c to display those messsages on the same console. Is it what this klogd command supposed to do?
-c is not necessarily the *same* console as you are working on. It sends output to /dev/console whereas *your* console is /dev/tty (and every process's /dev/tty is potentially different). By default this displays on the first DOS-lookalike screen that you get when you boot linux (assuming you don't boot to a GUI login manager with X-windows started). Did you know you probably have 6 of these? The left & right arrow keys move between them when you also hold down the Alt key. Or you can use Ctl-Alt-{F1 - F6} to change between them. But /dev/console messages only appear on the first one.

By the way, if you background the cat command, you can have its output appear on your screen as you do other stuff:

cat /proc/kmsg&
Avatar of Volga

ASKER

Duncan:

Thanks for your help. I just got into this Linux world and this world doesn't look so obvious. There are lots of things to know still.