Forum Discussion
Jeff_Morrison_4
Nimbostratus
Apr 05, 2006Logging to syslog from iRule
I am wanting to send HTTP information to my syslog-ng server. I have tried to add logging to my iRule but I don't see any information being sent to the Local0 files on the F5.
I would appreciate any help in setting up logging on a iRule.
Thanks!
15 Replies
- JRahm
Admin
logging will go to /var/log/ltm unless you've specified in your log statements for it to go elsewhere. - Jeff_Morrison_4
Nimbostratus
Yes I am aware that it go to the LTM file..I am just not seeing any information in the file. - JRahm
Admin
What does your rule look like? Perhaps your logging statements are never being called. - Jeff_Morrison_4
Nimbostratus
Copy of my iRule
when HTTP_REQUEST {
if { [HTTP::uri] contains "/Cust1"
or [HTTP::uri] contains "/Cust2"
or [HTTP::uri] contains "/Cust3"}{
pool WEB2-PICS
} elseif { [HTTP::uri] contains "/Cust4"
or [HTTP::uri] contains "/Cust5"}{
pool Prod_Web_Logic_7001
} elseif { [HTTP::uri] contains "/ABCDEFG"}{
HTTP::redirect https://www.domain.com/controller/
} else {
HTTP::redirect http://www.domain.com/eStmtF5Error.html
log local0.
}
} - Colin_Walker_12Historic F5 AccountAhh.
For the log command to function properly, you have to tell it what you want to log, not just tell it to log.
So for instance, if you changed your log line to:log local0. "Redirection to Error page"
Then you'd be able to see that message in your log file every time the rule processed that section of the code.
HTH,
-Colin - Jeff_Morrison_4
Nimbostratus
Thanks a lot for the help. Can you tell me how I would send ALL HTTP traffic to the LTM file so I can moitor it? - Colin_Walker_12Historic F5 AccountWell, first of all, I'm not sure you really want to pass all HTTP traffic to the LTM log, unless it's for a short period of testing or something to that effect.
Second, you can send any information you want to the log, but there isn't a command to generate a standardized log formatted entry.
So, you can create your own logging string, and have it fire for every HTTP_REQUEST event if that's what you're trying to track (like most webservers do).
This would simply be something like:when HTTP_REQUEST { log local0. "[IP::client_addr] - [clock format $time_now -format {%d/%m/%Y:%H:%M:%S}] [HTTP::request]" }
Of course you'd want to configure the logging string to fit your needs.
Colin - Jeff_Morrison_4
Nimbostratus
Thanks Colin...
I tried you exact syntax and I get the following error in the LTM file.
TCL error: Rule iRule_Test - can't read "time_now": no such variable while executing "clock format $time_now -format {%d/%m/%Y:%H:%M:%S}" - Colin_Walker_12Historic F5 AccountAdditionally, you can read more about the clock command, which is a default TCL command, here: Click here
-Colin - JRahm
Admin
I seem to remember unRuleY mentioning that you should be on 9.2 if you are going to use the clock command in production... just an FYI.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects