UNP Learn the 13th Chapter daemon and inetd Super server

Source: Internet
Author: User
Tags syslog

The syslogd daemon in a UNIX system is typically started by a system initialization script and runs continuously during system operation.

The SYSLOGD implementation originating from Berkeley performs the following steps at startup.

(1) Read the configuration file. Typically, the configuration file for/etc/syslog.conf specifies the various log messages that this daemon may charge, and how it should be handled.

(2) Create a UNIX domain datagram socket and give it a bundle of path names/var/run/log

(3) Create a UDP socket and bind it to Port 514.

(4) Open path name/dev/klog.

First, the Syslog function
#include <syslog.h>void syslog (intconstChar *message, ...); Priority: The combination of levels level and facility facility the message parameter resembles the printf format string, but adds %m, which is replaced with an error message corresponding to the current errno value.

The level of the log messages can be 0~7, they are arranged in order from high to low. If the sender does not specify a level value, then the default is Log_notice.

The log message contains a facility that identifies the type of message sending process. Default Log_user

For example, when rename unexpectedly fails, the daemon can execute the following call:

Syslog (log_info| Log_local2, "rename (%s,%s):%m", File1, file2);

#include <syslog.h>voidcharintint  facility); void closelog (void);
Ident: There are syslog messages about each log message before the string. The usual value is the program name
Options: The logic or composition of one or more constant values
Facility

Parameters for options

UNP Learn the 13th Chapter daemon and inetd Super server

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.