Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, This is my first post in this forum. I am currently working with Device driver where in i need to move some of my debug messages to /var/log/messages. Can ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28

    How to use logs under Device driver

    Hi,

    This is my first post in this forum.

    I am currently working with Device driver where in i need to move some of my debug messages to /var/log/messages.

    Can i use syslog function call under Device driver for this one?

    I forgot to mention. I need to move the debug messages to /var/log/messages only i don't want them to be printed on the stdout(i.e.,)console

    - Bala C-
    Last edited by cbalu; 02-04-2009 at 02:10 PM. Reason: Missed full context

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Is your device driver a kernel module? If it is then use printk...Hope this Helps...Gerard4143

    Welcome to the forums

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Its a I2C device driver for a custom hardware which is a kernel module only.

    If i am correct, using the printk function will make the debug message print in the console also. But, i am looking for a different solution wherein i need to print Driver Init and Exit messages only to the console and move rest of my debug messages under driver to /var/log/messages

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Check out this link...especially the section "replacing printks"

    The Linux Kernel Module Programming Guide


    Hope this helps...Gerard4143

  5. #5
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Gerard4143 thanks for your reply.

    But, i don't need this one.
    Just to make things clear.Can i use syslog() function call inside driver.

  6. #6
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Quote Originally Posted by cbalu View Post
    Can i use syslog() function call inside driver.
    Depends...is the driver a user program or is it a kernel module. If its a user program than yes you can use it...if its a kernel module then no....Hope this helps

  7. #7
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    It is a kernel module only.

    So i can't use syslog() function for this one.

    Is there any other way.
    I will explain my problem fully.

    I have a linux device driver(kernal module) for a custom hardware. In which i have printk statements inside module_init and module_exit functions which i need to show up in the console itself. But,when using the driver i have so many debug printk statements which i don't want to show up in the console.

    Instead move those messages to /var/log/messages so that while debugging the driver it will be usefull.

  8. #8
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Finally i found the solution which i was looking for about 2 days.

    I am posting the link for others reference

    This is the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...