How to display printk messages filtered by level as they come?
up vote
2
down vote
favorite
I wrote a hello word module that performs a printk when it is loaded in level ALERT and another printk when it is released with level INFO:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int init_hello(void)
{
printk(KERN_ALERT "init called in hellon");
return 0;
}
static void cleanup_hello(void)
{
printk(KERN_INFO "cleanup called in hellon");
}
module_init(init_hello);
module_exit(cleanup_hello);
Then I was trying to filter the kernel messages by its level, I did that using dmesg -l , but I want to see the messages as they appear, so I was using
tail -f /var/log/kern.log
Using this command I can see the messages, but how can I filter the messages by level?
I am using Ubuntu 14.04 with kernel 3.16.4
I then tried to print the messages to the console using:
echo 7 7 7 7 > /proc/sys/kernel/printk
But it doesn't print any message to the console. I tried to set the console-level using dmesg -n alert, but it doesn't work either, thus I am not sure what setting the console-level by dmesg or /proc/sys/kernel/printk does.
How can I use these levels efficiently?
Thanks for your help
kernel linux-kernel kernel-modules debugging
add a comment |
up vote
2
down vote
favorite
I wrote a hello word module that performs a printk when it is loaded in level ALERT and another printk when it is released with level INFO:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int init_hello(void)
{
printk(KERN_ALERT "init called in hellon");
return 0;
}
static void cleanup_hello(void)
{
printk(KERN_INFO "cleanup called in hellon");
}
module_init(init_hello);
module_exit(cleanup_hello);
Then I was trying to filter the kernel messages by its level, I did that using dmesg -l , but I want to see the messages as they appear, so I was using
tail -f /var/log/kern.log
Using this command I can see the messages, but how can I filter the messages by level?
I am using Ubuntu 14.04 with kernel 3.16.4
I then tried to print the messages to the console using:
echo 7 7 7 7 > /proc/sys/kernel/printk
But it doesn't print any message to the console. I tried to set the console-level using dmesg -n alert, but it doesn't work either, thus I am not sure what setting the console-level by dmesg or /proc/sys/kernel/printk does.
How can I use these levels efficiently?
Thanks for your help
kernel linux-kernel kernel-modules debugging
The items in/proc
are device pointers and setters. They are not files. Welcome!!!
– eyoung100
Oct 9 '14 at 20:46
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I wrote a hello word module that performs a printk when it is loaded in level ALERT and another printk when it is released with level INFO:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int init_hello(void)
{
printk(KERN_ALERT "init called in hellon");
return 0;
}
static void cleanup_hello(void)
{
printk(KERN_INFO "cleanup called in hellon");
}
module_init(init_hello);
module_exit(cleanup_hello);
Then I was trying to filter the kernel messages by its level, I did that using dmesg -l , but I want to see the messages as they appear, so I was using
tail -f /var/log/kern.log
Using this command I can see the messages, but how can I filter the messages by level?
I am using Ubuntu 14.04 with kernel 3.16.4
I then tried to print the messages to the console using:
echo 7 7 7 7 > /proc/sys/kernel/printk
But it doesn't print any message to the console. I tried to set the console-level using dmesg -n alert, but it doesn't work either, thus I am not sure what setting the console-level by dmesg or /proc/sys/kernel/printk does.
How can I use these levels efficiently?
Thanks for your help
kernel linux-kernel kernel-modules debugging
I wrote a hello word module that performs a printk when it is loaded in level ALERT and another printk when it is released with level INFO:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int init_hello(void)
{
printk(KERN_ALERT "init called in hellon");
return 0;
}
static void cleanup_hello(void)
{
printk(KERN_INFO "cleanup called in hellon");
}
module_init(init_hello);
module_exit(cleanup_hello);
Then I was trying to filter the kernel messages by its level, I did that using dmesg -l , but I want to see the messages as they appear, so I was using
tail -f /var/log/kern.log
Using this command I can see the messages, but how can I filter the messages by level?
I am using Ubuntu 14.04 with kernel 3.16.4
I then tried to print the messages to the console using:
echo 7 7 7 7 > /proc/sys/kernel/printk
But it doesn't print any message to the console. I tried to set the console-level using dmesg -n alert, but it doesn't work either, thus I am not sure what setting the console-level by dmesg or /proc/sys/kernel/printk does.
How can I use these levels efficiently?
Thanks for your help
kernel linux-kernel kernel-modules debugging
kernel linux-kernel kernel-modules debugging
edited Oct 9 '14 at 21:03
asked Oct 9 '14 at 20:37
Lilás
1114
1114
The items in/proc
are device pointers and setters. They are not files. Welcome!!!
– eyoung100
Oct 9 '14 at 20:46
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56
add a comment |
The items in/proc
are device pointers and setters. They are not files. Welcome!!!
– eyoung100
Oct 9 '14 at 20:46
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56
The items in
/proc
are device pointers and setters. They are not files. Welcome!!!– eyoung100
Oct 9 '14 at 20:46
The items in
/proc
are device pointers and setters. They are not files. Welcome!!!– eyoung100
Oct 9 '14 at 20:46
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
On Ubuntu 16.04, util-linux 2.27.1, you can do:
dmesg --level err,warn --raw -w
where:
-w
follows the messages as they come
--level
restricts which levels will show
--raw
shows the level at the beginning of the message e.g. as<3>
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f160294%2fhow-to-display-printk-messages-filtered-by-level-as-they-come%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
On Ubuntu 16.04, util-linux 2.27.1, you can do:
dmesg --level err,warn --raw -w
where:
-w
follows the messages as they come
--level
restricts which levels will show
--raw
shows the level at the beginning of the message e.g. as<3>
add a comment |
up vote
0
down vote
On Ubuntu 16.04, util-linux 2.27.1, you can do:
dmesg --level err,warn --raw -w
where:
-w
follows the messages as they come
--level
restricts which levels will show
--raw
shows the level at the beginning of the message e.g. as<3>
add a comment |
up vote
0
down vote
up vote
0
down vote
On Ubuntu 16.04, util-linux 2.27.1, you can do:
dmesg --level err,warn --raw -w
where:
-w
follows the messages as they come
--level
restricts which levels will show
--raw
shows the level at the beginning of the message e.g. as<3>
On Ubuntu 16.04, util-linux 2.27.1, you can do:
dmesg --level err,warn --raw -w
where:
-w
follows the messages as they come
--level
restricts which levels will show
--raw
shows the level at the beginning of the message e.g. as<3>
answered May 22 at 12:05
Ciro Santilli 新疆改造中心 六四事件 法轮功
4,84324039
4,84324039
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f160294%2fhow-to-display-printk-messages-filtered-by-level-as-they-come%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The items in
/proc
are device pointers and setters. They are not files. Welcome!!!– eyoung100
Oct 9 '14 at 20:46
Yes, of course, I will change the text, but you got what I meant :)
– Lilás
Oct 9 '14 at 20:56