Using syslog with i2Rest Server

From i2Rest
Jump to: navigation, search


Depending on defined DEBUG level, i2Rest Server can produce a lot of messages. These messages can be sent to stdout or to syslog server. Using syslog allows you to centralize the collection and processing of messages from different sources, as well as routing messages to other syslog servers.

Local syslog server

i2Rest Server can send messages to local or remote syslog server. It is possible to start local syslog server on local IBM i server.
IBM i PASE includes standalone syslogd server, that can be used as a starting point to process syslog messages from i2Rest Server. You can find detailed information how to start syslogd daemon on IBM i here.
To simplify the task of starting the server, we prepared the following brief instructions:

  1. Prepare file syslog.conf and put it on IFS folder, for example at /usr/i2rest/syslog.conf. Enter following text in syslog.conf (you can change path and name of syslog.out to other desired value):
    *.debug /usr/i2rest/syslog.out rotate size 500k time 1d
  2. Create file to store syslog messages, don't forget to enter correct name of syslog.out file:
    STRQSH CMD('touch /usr/i2rest/syslog.out')
  3. Submit syslogd daemon with following command:
    SBMJOB CMD(CALL PGM(QP2SHELL) PARM('/QIBM/ProdData/OS400/PASE/sbin/syslogd' '-a' '-n' '-f/usr/i2rest/syslog.conf')) ALWMLTTHD(*YES)

With these settings, the local syslog server will be launched. The server will listen to calls to port 514 and will save messages in file /usr/i2rest/syslog.out. The file will be recreated when it reaches 500k or once a day. Archived copies will be kept at /usr/i2rest.
You can use one syslog server for several i2Rest Server instances. If required, you can setup rules for routing messages to other syslog servers in syslog.conf.

Clear syslog.out file

To clear syslog.out file, use following qshell command. You can use this command without stopping syslog server
cat /dev/null > /usr/i2rest/syslog.out

i2Rest Server settings for syslog

Setting up i2Rest Server to work with syslog is quite simple - just specify the server address in the configuration file, parameter "syslog":

{
...
   "debug"  : 7, "syslog":"udp://localhost:514", 
...
}

You can use different syslog server settings for each i2Rest Server gate - see details in gate object