KB Article #44412

How to write a custom message in the Gateway log

Problem

How to write a custom message in the Gateway log file (log.dat)?


Resolution


Gateway ships with a helper utility called "logwrite". The syntax is:


logwrite 'type' 'message


where 'type' is a single character (case-insensitive) representing the message type:


s = success
i = information
w = warning
e = error
f = fatal


and 'message' is the message to write in the log.


For example :
logwrite I "script toto running !"


This can be called at the command line, in a decision rule, or in a Perl user exit. (In the latter, call it like any OS function: system("logwrite I message").)



In C user exits, use instead the LogPrintf function. It also takes two arguments, where the first one is the message type, one of the following:


ITP_LOG_SUCCESS
ITP_LOG_INFO
ITP_LOG_WARNING
ITP_LOG_ERROR
ITP_LOG_FATAL


and the second is the actual message.