Kernel logging: APIs and implementation

Kernel API

Logging within the kernel is performed using the printk function

int printk( const char * fmt, ... );
The kernel code simply defines the log level as the first argument of the message, as illustrated in the following example for a critical message:
printk( KERN_CRIT "Error code %08x.\n", val );

Note that the first argument is not an argument at all, as no comma (,) separates the level (KERN_CRIT) from the format string.

Table 1. Log levels, symbolics, and uses
Symbolic String Usage
KERN_EMERG <0> Emergency messages (precede a crash)
KERN_ALERT <1> Error requiring immediate attention
KERN_CRIT <2> Critical error (hardware or software)
KERN_ERR <3> Error conditions (common in drivers)
KERN_WARNING <4> Warning conditions (could lead to errors)
KERN_NOTICE <5> Not an error but a significant condition
KERN_INFO <6> Informational message
KERN_DEBUG <7> Used only for debug messages
KERN_DEFAULT <8> Default kernel logging level
KERN_CONT <9> Continuation of a log line (avoid adding new time stamp)

Note that if a caller does not provide a log level within printk, a default of KERN_WARNING is automatically used.

At this point, you‘ve explored the API used to insert log messages into the kernel ring buffer. Now, let‘s look at the method used to migrate data from the kernel into the host.

## Printk source code

Kernel logging and interface

Access to the log buffer is provided at the core through the multi-purpose syslog system call.

The syslog call serves as the input/output (I/O) and control interface to the kernel‘s log message ring buffer.

User space applications

References

Technorati 标签: kernel,log

时间: 2024-11-05 14:38:23

Kernel logging: APIs and implementation的相关文章

SLF4J user manual

引用:https://www.slf4j.org/manual.html The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks, such as java.util.logging, logback and log4j. SLF4J allows the end-user to plug in the desired lo

Windows Kernel Security Training Courses

http://www.codemachine.com/courses.html#kerdbg Windows Kernel Internals for Security Researchers This course takes a deep dive into the internals of the Windows kernel from a security perspective. Attendees learn about behind the scenes working of va

Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)

Acknowledgments I would like to thank Jacob Kjome for reviewing early drafts of this document. His comments helped to clarify several important points. Jake also keeps reminding us on the log4j-dev mailing list that the child-parent delegation model

日志组件系列:(2)commons logging和log4j实战

(1).下载组件,引入jar包 (2).配置 (3).使用API 1.下载组件,引入jar包 jar包 下载地址 log4j-1.2.17.jar http://logging.apache.org/log4j/1.2/ commons-logging-1.2.jar http://commons.apache.org/proper/commons-logging/download_logging.cgi 2.配置 在项目的src目录下添加log4j.properties文件,配置如下: log

PatentTips - Hardware virtualization such as separation kernel hypervisors

BACKGROUND 1. Field Innovations herein pertain to computer virtualization, computer security and/or data isolation, and/or the use of a separation kernel hypervisor (and/or hypervisor), such as to detect and/or prevent malicious code and which may in

What is logging

Logging is a systematic and controlled way of representing the state of an application in a human-readable fashion. it is systematic it is controlled it represents an application's state evaluating a logging package configuration flexibility output e

Java性能提示(全)

http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLists and ArrayLists (and Vectors) (Page last updated May 2001, Added 2001-06-18, Author Jack Shirazi, Publisher OnJava). Tips: ArrayList is faster than

SSH系列:(4)Spring

(1)引入jar包 (2)配置 (3)测试 1.引入jar包 添加User Library,名为spring-core 引入spring-core的jar包(spring-framework-3.2.5.RELEASE) spring-beans-3.2.5.RELEASE.jar spring-context-3.2.5.RELEASE.jar spring-core-3.2.5.RELEASE.jar spring-expression-3.2.5.RELEASE.jar 注意:这里没有添加

111个知名Java项目集锦,包括url和描述

转:http://www.cnblogs.com/wangs/p/3282183.html 项目名称   项目描述 ASM Java bytecode manipulation framework AspectWerkz AspectWerkz - Dynamic AOP for Java Axis Axis - an implementation of the SOAP (Simple Object Access Protocol) submission to W3C Batik Batik