Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:41:59+00:00 2026-06-11T14:41:59+00:00

Since it’s a Linux question, I’ll note I’m using OpenSUSE 12.1 I’m running a

  • 0

Since it’s a Linux question, I’ll note I’m using OpenSUSE 12.1

I’m running a kernel module, basically it’s a CAN bus simulator, and it prints messages via printk() whenever there is activity on the ‘bus’.

I’m tracing the messages right now with sudo cat /proc/kmsg, but when I start putting other “devices” on the “bus” the kmsg traffic is greatly incressed and it’s hard to find my messages.

Is there anyway to pipe the “printk” messages from one specific process to a file?

EDIT
I see now there are possibilties if I add specific tags to my debug messages, are there any other ways?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:42:00+00:00Added an answer on June 11, 2026 at 2:42 pm

    yes, you can. All kernel messages can hold syslog-ng daemon. For this daemon you can write custom rules and put all messages from your module to specific file. Take first look at /etc/syslog-ng/syslog-ng.conf

    update

    By default, all kernel print and printk functions put messages to kernel ring buffer. Userspace programs can access to this ring buffer thought /proc/kmsg file.

    Syslog-ng will read data from /proc/kmsg, then, via filter (filter is just special pattern) grep output and put data in different output (in this example it will be just text files). If in output buffer we will find output from kernel module “hello”, syslog-ng will put messages to /var/log/hello, all other messages will go to /var/log/messages

    Module source

    #include <linux/module.h>       
    #include <linux/kernel.h>       
    
    #define MODNAME "[hello]"
    
    int init_module(void)
    {
            printk(KERN_WARNING MODNAME "Hello world 1.\n");    
            return 1;
    }
    
    void cleanup_module(void)
    {
            printk(KERN_ALERT "Goodbye world 1.\n");
    }
    

    After insmod

    insmod hello-1.ko

    in /var/log/messages you can find:

    Sep 20 17:46:20 ns1 kernel: [96643.968650] [hello]Hello world 1.

    ok, lets configure syslog-ng to catch grep log message (by using pattern [hello])

    $cat /etc/syslog-ng/syslog-ng.conf

    @version: 3.2
    # $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/syslog-ng.conf.gentoo.3.2,v 1.1 2011/01/18 17:44:14 mr_bones_ Exp $
    #
    # Syslog-ng default configuration file for Gentoo Linux
    
    options {
            chain_hostnames(no);    
            stats_freq(43200);
            mark_freq(3600);
    };
    
    source src {
        unix-stream("/dev/log" max-connections(256));
        internal();
        file("/proc/kmsg");
    };
    
    destination messages { file("/var/log/messages"); };
    # output file for ower module
    destination hello_messages { file("/var/log/hello"); };   
    
    # grep patterns for ower module
    filter f_hello { match("hello" value("MESSAGE")); };
    filter f_kernel { facility(kern); };
    
    log { source(src); destination(messages); };
    log { source(src); destination(console_all); };
    
    # target for logging    
    log { source(src); filter(f_hello); filter(f_kernel); destination(hello_messages); };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since input and raw_input() stop the program from running anymore, I want to use
Since each thread has its own stack, its private data can be put on
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain
Since I'm running my app on the Bamboo stack I'm precompiling my assets and
Since i'm not strong in asp.net, probably my question will sound silly. I've got
Since multiple requests can slow down the speed at which a site loads, I
Since trees are special kind of graphs or we can categorize trees in DAG(Directed
Since Java char is 16 bit long, I am wondering how can it represent
Since I moved a PHP app to a new server (PHP/5.3.8 running as Apache
Since I started using Fireworks CS5.1, and it doesn't matter how I write the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.