Log Http Tcp Udp To Syslogng¶
Description¶
iRule Source¶
when HTTP_REQUEST {
# set the URL here, log it on the response
set url [HTTP::host][HTTP::uri]
set vip [IP::local_addr]:[TCP::local_port]
}
when HTTP_RESPONSE {
set client [IP::client_addr]:[TCP::client_port]
set node [IP::server_addr]:[TCP::server_port]
set nodeResp [HTTP::status]
# log connection info
log local0.info "Client: $client -> VIP:$vip$url -> Node: $node with response $nodeResp"
}
when CLIENT_ACCEPTED {
set vip [IP::local_addr]:[TCP::local_port]
}
when SERVER_CONNECTED {
set client "[IP::client_addr]:[TCP::client_port]"
set node "[IP::server_addr]:[TCP::server_port]"
}
when CLIENT_CLOSED {
# log connection info
log local0.info "Client $client -> VIP: $vip -> Node: $node"
}
when CLIENT_ACCEPTED {
set vip [IP::local_addr]:[UDP::local_port]
}
when SERVER_CONNECTED {
set client "[IP::client_addr]:[UDP::client_port]"
set node "[IP::server_addr]:[UDP::server_port]"
}
when CLIENT_CLOSED {
# log connection info
log local0.info "Client $client -> VIP: $vip -> Node: $node"
}
Mar 1 08:34:01 tmm tmm[730]: Rule HTTP_logging <HTTP_RESPONSE>: Client: 192.168.42.26:4746 VIP:172.25.2.12:80 to server: 172.25.2.233:80 for 172.25.2.12/ with response 200
# local0.info send logging entries to remote syslog server
filter f_local0.info {
facility(local0) and level(info) and match("logging");
};
# destination can be a hostname or IP address
destination d_logging {
tcp("syslog.myhost.com" port (5000));
};
log {
source(local);
filter(f_local0.info);
destination(d_logging);
};
# local0.* /var/log/ltm
filter f_local0 {
facility(local0) and level(info..emerg) and not match("logging");
};
destination d_ltm {
file("/var/log/ltm" create_dirs(yes));
};
log {
source(local);
filter(f_local0);
destination(d_ltm);
};
bigstart restart syslog-ng
The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.