IRule to log to custom file

This is a simple IRule that logs the URLs tried to be accesed in the virtual server where the IRule has been applied:

when HTTP_REQUEST {
log local0.info "[IP::client_addr] [HTTP::host][HTTP::uri]"
}

As expected, this lines would be logged to /var/log/ltm file

To send those messages to the custom log file, it is as simple as prepending the configured syslog string (in this example #DEBUG#):

when HTTP_REQUEST {
log local0.info "#DEBUG# [IP::client_addr] [HTTP::host][HTTP::uri]"
}

Check logs

After applying this last example IRule, new messages would be logged to the custom file:

# tail -f /var/log/customlog
Nov  8 09:33:03 BigIP1 tmm1[12686]: Rule /Common/IRULE_TEST_LOG <HTTP_REQUEST>: #DEBUG# 10.2.4.10 myweb.domain.com/folder

Was this article helpful?

Related Articles

Leave A Comment?