Name

SysLog — instruct Interchange to log to Unix system's log (syslog)

SYNOPSIS

DESCRIPTION

The directive configures syslog(8) logging for Interchange.

Besides just tuning syslog facility and priority settings, it is also possible to specify external command to invoke for sending syslog messages. This also means it is possible to hook into the message logging system and route messages where ever you want. For example, a custom wrapper can be created to log to a database. See an example of it in the section called “EXAMPLES”.

DIRECTIVE TYPE AND DEFAULT VALUE

Global directive

EXAMPLES

Example: Simple syslog setup

SysLog  command  /usr/bin/logger
SysLog  tag      int1
SysLog  alert    local3.warn
SysLog  warn     local3.info
SysLog  info     local3.info
SysLog  debug    local3.debug

The above would cause messages to be logged with the command /usr/bin/logger -t int1 -p local3.alert ....

The generated system log entries would look somewhat like the following:

Oct 26 17:30:11 bill int1: Config 'co' at server startup
Oct 26 17:30:11 bill int1: Config 'homefn' at server startup
Oct 26 17:30:11 bill int1: Config 'simple' at server startup
Oct 26 17:30:11 bill int1: Config 'test' at server startup
Oct 26 17:30:13 bill int1: START server (2345) (INET and UNIX)

Example: Sending facility 'local3' messages to appropriate log file

As you might know, messages sent using syslog reach the syslog daemon sooner or later. There, they are examined and "routed" to their final destination. For BSD-compatible syslog daemons, the configuration file is probably /etc/syslog.conf, and the configuration snippet needed to route Interchange messages to /var/log/interchange.log is as follows:

# Log local3 stuff to Interchange log
local3.*                /var/log/interchange.log

Example: Custom logging script for logging to a database

#!/usr/bin/perl
 
my $script_name = "logdatabase";
use DBI;
use Getopt::Std;
 
getopts('d:p:T:k:') or die "$script_name options: $@\n";
 
use vars qw/$opt_d $opt_p $opt_T $opt_k/;
 
my $dsn   = $opt_d || $ENV{DBI_DSN};
my $template = $opt_T
    || "insert into log values ('~~KEY~~', '~~LEVEL~~', '~~MSG~~')";
 
my $dbh = DBI->connect($dsn)
    or die "$script_name cannot connect to DBI: $DBI::errstr\n";
 
my %data;
 
$data{KEY} = $opt_k || '';
 
local ($/);
$data{MSG} = <>;
 
$data{LEVEL} = $opt_p || 'interchange.info';
 
$template =~ s/\~\~(\w+)\~\~/$dbh->quote($data{$1})/;
 
my $sth = $dbh->prepare($template)
    or die "$script_name error executing query: $template\n";
 
$sth->execute()
    or die "$script_name error executing query: $template\n";
 
exit;

NOTES

AVAILABILITY

SysLog is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: lib/Vend/Config.pm
Line 509

['SysLog',       'hash',            undef],

Source: lib/Vend/Config.pm
Line 3188 (context shows lines 3188-3205)

sub parse_hash {
my($item,$settings) = @_;
if (! $settings) {
  return $HashDefaultBlank{$item} ? '' : {};
}

my $c;

if(defined $C) {
  $c = $C->{$item} || {};
}
else {
  no strict 'refs';
  $c = ${"Global::$item"} || {};
}

return hash_string($settings,$c);
}

AUTHORS

Interchange Development Group

SEE ALSO

DebugFile(7ic), Logging(7ic), ErrorFile(7ic)

DocBook! Interchange!