WebKit uses syslog()
extensively to record its actions and
report errors. You too can use syslog()
as a general-purpose
logging and error-trapping tool in your WebKit applications.
Here's how.
The following discussion assumes that you know what syslog()
does and how to set up a syslog.conf file. If you do not already know
about syslog()
, syslogd
, and the /etc/syslog.conf
file, you will definitely need to read syslog.conf(4)
. But
in the meantime, here's a very brief overview.
The standard way to output debugging or logging information in a
Unix program is through the system logging daemon syslogd
.
WebKit, as you would expect, gives you an easy way to do
this too.
Whenever you wish to write to syslog, execute the command
SYSLOG SEVERITY <nSeverity> <cData>
or call the function
wksyslog (nSeverity, cData)
openlog()
is called automatically upon startup. (At the moment
you have to log all messages using Local Level 0.) The library
code itself generates a lot more useful syslog stuff.
To use the syslog feature, you need to edit /etc/syslog.conf
and restart the syslogd by sending it a SIGHUP signal. For example:
------------/etc/syslog.conf, cut here--------
# WebKit logging.
# The whitespace area is made of TABS, not spaces!
local0.debug /var/log/webkit-server.log
local1.debug /var/log/webkit-client.log
------------/etc/syslog.conf, cut here--------
# vi /etc/syslog.conf
# ps
PID TTY STAT TIME COMMAND
.
.
.
28 con S 5:25 /usr/sbin/crond -l10
47 con S 59:07 /usr/sbin/syslogd
49 con SW 0:00 (klogd)
.
.
.
# kill -SIGHUP 47
For more information on how to use and configure syslogd
,
run man syslogd
.
Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter