Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

18.2.1 openlog

The symbols referred to in this section are declared in the file syslog.h.

— Function: void openlog (char *ident, int option,

int facility)

openlog opens or reopens a connection to Syslog in preparation for submitting messages.

ident is an arbitrary identification string which future syslog invocations will prefix to each message. This is intended to identify the source of the message, and people conventionally set it to the name of the program that will submit the messages.

openlog may or may not open the /dev/log socket, depending on option. If it does, it tries to open it and connect it as a stream socket. If that doesn't work, it tries to open it and connect it as a datagram socket. The socket has the “Close on Exec” attribute, so the kernel will close it if the process performs an exec.

You don't have to use openlog. If you call syslog without having called openlog, syslog just opens the connection implicitly and uses defaults for the information in ident and options.

options is a bit string, with the bits as defined by the following single bit masks:

LOG_PERROR
If on, openlog sets up the connection so that any syslog on this connection writes its message to the calling process' Standard Error stream in addition to submitting it to Syslog. If off, syslog does not write the message to Standard Error.
LOG_CONS
If on, openlog sets up the connection so that a syslog on this connection that fails to submit a message to Syslog writes the message instead to system console. If off, syslog does not write to the system console (but of course Syslog may write messages it receives to the console).
LOG_PID
When on, openlog sets up the connection so that a syslog on this connection inserts the calling process' Process ID (PID) into the message. When off, openlog does not insert the PID.
LOG_NDELAY
When on, openlog opens and connects the /dev/log socket. When off, a future syslog call must open and connect the socket.

Portability note: In early systems, the sense of this bit was exactly the opposite.

LOG_ODELAY
This bit does nothing. It exists for backward compatibility.

If any other bit in options is on, the result is undefined.

facility is the default facility code for this connection. A syslog on this connection that specifies default facility causes this facility to be associated with the message. See syslog for possible values. A value of zero means the default default, which is LOG_USER.

If a Syslog connection is already open when you call openlog, openlog “reopens” the connection. Reopening is like opening except that if you specify zero for the default facility code, the default facility code simply remains unchanged and if you specify LOG_NDELAY and the socket is already open and connected, openlog just leaves it that way.


 
 
  Published under the terms of the GNU General Public License Design by Interspire