📄 closelog.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>closelog</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_001_530"> </a>NAME</h4><blockquote>closelog, openlog, setlogmask, syslog - control system log</blockquote><h4><a name = "tag_000_001_531"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="syslog.h.html">syslog.h</a>>void closelog(void);void openlog(const char *<i>ident</i>, int <i>logopt</i>, int <i>facility</i>);int setlogmask(int <i>maskpri</i>);void syslog(int <i>priority</i>, const char *<i>message</i>, ... /* <i>arguments</i> */);</code></pre></blockquote><h4><a name = "tag_000_001_532"> </a>DESCRIPTION</h4><blockquote>The<i><a href="syslog.html">syslog()</a></i>function sends a message to an implementation-dependent logging facility, whichmay log it in an implementation-dependent system log, write it to the system console, forward it to a list of users, or forward it to the logging facility on another host over the network. The logged message includes a message headerand a message body. The message header contains at least a timestamp and a tagstring.<p>The message body is generated from the <i>message</i> and following argumentsin the same manner as if these were arguments to<i><a href="printf.html">printf()</a></i>,except that occurrences of %m in the format string pointed to by the<i>message</i> argument are replaced by the error message string associatedwith the current value of <i>errno</i>. A trailing newline character is addedif needed.<p>Values of the <i>priority</i> argument are formed by ORing together a severitylevel value and an optional facility value. If no facility value isspecified, the current default facility value is used.<p>Possible values of severity level include:<dl compact><dt>LOG_EMERG<dd>A panic condition.<dt>LOG_ALERT<dd>A condition that should be corrected immediately, such as a corrupted systemdatabase.<dt>LOG_CRIT<dd>Critical conditions, such as hard device errors.<dt>LOG_ERR<dd>Errors.<dt>LOG_WARNING<dd>Warning messages.<dt>LOG_NOTICE<dd>Conditions that are not error conditions, but that may require specialhandling.<dt>LOG_INFO<dd>Informational messages.<dt>LOG_DEBUG<dd>Messages that contain information normally of use only when debugging aprogram.</dl><p>The facility indicates the application or system component generatingthe message. Possible facility values include:<dl compact><dt>LOG_USER<dd>Messages generated by random processes. This is the default facilityidentifier if none is specified.</dl><dl compact><dt>LOG_LOCAL0<dd>Reserved for local use.<dt>LOG_LOCAL1<dd>Reserved for local use.<dt>LOG_LOCAL2<dd>Reserved for local use.<dt>LOG_LOCAL3<dd>Reserved for local use.<dt>LOG_LOCAL4<dd>Reserved for local use.<dt>LOG_LOCAL5<dd>Reserved for local use.<dt>LOG_LOCAL6<dd>Reserved for local use.<dt>LOG_LOCAL7<dd>Reserved for local use.</dl><p>The<i><a href="openlog.html">openlog()</a></i>function sets process attributes that affect subsequent calls to<i><a href="syslog.html">syslog()</a></i>.The<i>ident</i>argument is a string that is prepended to every message. The<i>logopt</i>argument indicates logging options. Values for<i>logopt</i>are constructed by a bitwise-inclusive OR of zero or more of the following:<dl compact><dt>LOG_PID<dd>Log the process ID with each message. This is useful for identifying specificprocesses.<dt>LOG_CONS<dd>Write messages to the system console if they cannot be sent to the loggingfacility. The<i><a href="syslog.html">syslog()</a></i>function ensures that the process does not acquire theconsole as a controlling terminal in the process of writing themessage.<dt>LOG_NDELAY<dd>Open the connection to the logging facility immediately. Normally the open isdelayed until the first message is logged. This is useful for programs thatneed to manage the order in which file descriptors are allocated.<dt>LOG_ODELAY<dd>Delay open until<i><a href="syslog.html">syslog()</a></i>is called.<dt>LOG_NOWAIT<dd>Do not wait for child processes that may have been created during thecourse of logging the message.This option should be used by processes that enable notification ofchild termination using SIGCHLD, since<i><a href="syslog.html">syslog()</a></i>may otherwise block waiting for a child whose exit status has already beencollected.</dl><p>The<i>facility</i>argument encodes a default facility to be assigned to all messages that do nothave an explicit facility already encoded. The initial default facility isLOG_USER.<p>The<i><a href="openlog.html">openlog()</a></i>and<i><a href="syslog.html">syslog()</a></i>functions may allocate a file descriptor. It is not necessary to call<i><a href="openlog.html">openlog()</a></i>prior to calling<i><a href="syslog.html">syslog()</a></i>.<p>The<i>closelog()</i>function closes any open file descriptors allocated by previous calls to<i><a href="openlog.html">openlog()</a></i>or<i><a href="syslog.html">syslog()</a></i>.<p>The<i><a href="setlogmask.html">setlogmask()</a></i>function sets the log priority mask for the current process to<i>maskpri</i>and returns the previous mask. If the <i>maskpri</i> argument is 0, thecurrent log mask is not modified. Calls by the current process to<i><a href="syslog.html">syslog()</a></i>with a priority not set in<i>maskpri</i>are rejected. The default log mask allows all priorities to be logged.A call to openlog is not required prior to calling<i><a href="setlogmask.html">setlogmask()</a></i>.<p>Symbolic constants for use as values of the <i>logopt</i>, <i>facility</i>,<i>priority</i>, and <i>maskpri</i> arguments are defined in the<<b>syslog.h</b>> header.</blockquote><h4><a name = "tag_000_001_533"> </a>RETURN VALUE</h4><blockquote>The<i><a href="setlogmask.html">setlogmask()</a></i>function returns the previous log priority mask.The<i>closelog()</i>,<i><a href="openlog.html">openlog()</a></i>and<i><a href="syslog.html">syslog()</a></i>functions return no value.</blockquote><h4><a name = "tag_000_001_534"> </a>ERRORS</h4><blockquote>No errors are defined.</blockquote><h4><a name = "tag_000_001_535"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_536"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_537"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_538"> </a>SEE ALSO</h4><blockquote><i><a href="printf.html">printf()</a></i>,<i><a href="syslog.h.html"><syslog.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -