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.
VolgaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duncan RoeSoftware DeveloperCommented:
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.
0
VolgaAuthor Commented:
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.
0
Duncan RoeSoftware DeveloperCommented:
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)
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

VolgaAuthor Commented:
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.

0
Duncan RoeSoftware DeveloperCommented:
Your simplest method is to dispense with klogd altogether. In the attached example
- make sure /proc/kmsg exists (it's possible though unlikely that it doesn't)
- find out the pid of klogd
- kill klogd
- make sure it's gone
- cat /proc/kmsg directly in your window of choice - you'll see everything

I plugged in a USB stick to generate some messages. You don't get timestamps like you would with klogd / syslogd but I imagine that doesn't worry you
07:51:03# ls -l /proc/kmsg 
-r--------  1 root root 0 2008-02-04 07:51 /proc/kmsg
07:54:46# ps ax|grep klogd
 2208 ?        Ss     0:00 /usr/sbin/klogd -c 3 -x
 2214 pts/9    S+     0:00 grep klogd
07:55:00# kill 2208
07:55:45# ps ax|grep klogd
 2216 pts/9    S+     0:00 grep klogd
07:59:17# cat /proc/kmsg
<7>hub 1-0:1.0: state 7 ports 4 chg 0000 evt 0004
<7>ehci_hcd 0000:00:05.2: GetStatus port 2 status 001803 POWER sig=j CSC CONNECT
<7>hub 1-0:1.0: port 2, status 0501, change 0001, 480 Mb/s
<7>hub 1-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x501

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VolgaAuthor Commented:
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?
0
Duncan RoeSoftware DeveloperCommented:
-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&
0
VolgaAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.