Fedora14printk () cannot be displayed on the terminal

Source: Internet
Author: User
Tags dmesg
Recently, the output information of kernel module printk cannot be displayed on the terminal. Solution: cause 1: printk () has a log-level field, if the log level of this field is higher than the default Log Level of the console, it will be printed (the smaller the value, the higher the log level, divided into a total of 8 log levels from 0 to 7 ). There is a simple way to change the log level of the current terminal, echo8 & gt;/proc/sys/kernel/printk. Theoretically, printk can be output to the terminal.

Recently, the output information of kernel module printk cannot be displayed on the terminal.

Solution:

Cause 1: printk () has a log-level field. If the log level of this field is higher than the default Log Level of the console, it is printed (the smaller the value, the higher the log level, it can be divided into 8 log levels from 0 to 7 ). There is a simple way to change the log level of the current terminal, echo 8>/proc/sys/kernel/printk. Theoretically, printk can be output to the terminal. But I do not.

Cat/proc/sys/kernel/printk

8 4 1 7
Four numeric meanings

/Proc/sys/kernel/printk
The four values in this file are console_loglevel, default_mes-
Sage_loglevel, minimum_lele_level and default_con-
Sole_loglevel. These values influence printk () behavior when
Printing or logging error messages. See syslog (2) for more info
On the different loglevels. Messages with a higher priority
Than console_loglevel will be printed to the console. Messages
Without an explicit priority will be printed with priority
Default_message_level. minimum_console_loglevel is the minimum
(Highest) value to which console_loglevel can be set.
Default_console_loglevel is the default value for con-
Sole_loglevel.

Cause 2: The syslogd daemon rules are incorrect./etc/syslog. conf defines some column rules, including the processing rules for messages of the number kernel. The syslogd daemon in Fedora is called rsyslogd, and its rule configuration file is called rsyslog. conf, with a line "# kern. */dev/console "it means to output all log-level kernel logs to/dev/console, that is, our terminal. We only need to remove the '#' of the row and restart it. Theoretically, the kernel log (printk () output is also the kernel log) will be output to the terminal. But I couldn't find the file that my eldest brother said.

Cause 3: The klogd and syslogd daemon in the system cannot be output to the terminal regardless of the log level.

If you cannot see the output of printk on the terminal, you can view the/var/log/messages file by running the dmesg command, or view the/proc/kmsg file to obtain information, or press ctrl + alt + f2 ~ F6 enters the system text mode to load the module, so that you can see the information output by prink (). Of course, the rules described in cause 1 are exactly matched here. It seems that this method is reliable.

Attached to a large fairy, the reason is:

Printk () does not hit stdout or stderr, so you cannot directly see it.

You can view it through dmesg.

The description of the role of printk () is taken from linux kernel primer:
Printk ()

One of the most basic kernel messaging systems is the printk () function. the kernel uses printk () as opposed to printf () because the standard C library is not linked to the kernel. printk () uses the same interface as printf () does and displays up to 1,024 characters to the console. the printk () function operates by trying to grab the console semaphore, place the output into the console's log buffer, and then call the console driver to flush the buffer. if printk () cannot grab the console semaphore, it places the output into the log buffer and relies on the process that has the console semaphore to flush the buffer. the log-buffer lock is taken before printk () places any data into the log buffer, so concurrent callto printk () do not trample each other. if the console semaphore is being held, numerous callto printk () can occur before the log buffer is flushed. so, do not rely on printk () statements to indicate any program timing.
Printk () knocked out the console buffer provided by the kernel, and then printed it by the console driver.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.