This article describes how to use the policy-based logging on a NetScaler appliance to log an HTTP header not supported by the NetScaler Web Logging (NSWL) feature.
To use the policy-based logging on a NetScaler appliance to log an HTTP header not supported by the NSWL feature, compete the following procedure:
Expand the System node in the Navigation pane.
Expand the Auditing node and then select Message Actions.
Click Add on the Message Actions page.
Specify a name for the action in the Name field and an appropriate severity level for the message.
Specify the log message to be transmitted. The following is a sample log message for your reference:
"X-FORWARDED FOR DETECTED” + HTTP.REQ.HEADER("x-forwarded-for")
Optionally, select the Log in newnslog option.
Check the Bypass Safety Check option, and click OK.
Expand the Rewrite node in Navigation pane and then select Policies.
Click Add in Rewrite Policies page and then specify the name for the policy.
Select NOREWRITE from the Action list.
Ensure that Undefined-Result Action has the default value.
From the Log Action list, select the log action name you created in Step 4.
Specify the Expression that must trigger the policy.
Click Create and then Close.
Expand the Load Balancing node in Navigation pane and then select Virtual Servers.
Open the virtual server to which you want to bind the policy from the Virtual Server page.
Activate the Policies tab.
Click Rewrite (Request) and then click Insert Policy.
Select the policy that you created in Step 14 from the Policy Name list and then click Create.
Run the following command to add the new syslog receiver:
add audit syslogAction log-rewrite 101.111.111.1 -logLevel CRITICAL -acl ENABLED -userDefinedAuditlog YES
Run the following command to set the audit syslogPolicy to use the new server:
add audit syslogPolicy log-rewrite-policy ns_true log-rewrite
Run the following command to globally bind the log policy, so when the message action is triggered, you know where to send it:
bind system global log-rewrite-policy -priority 100
Add custom logging to a virtual server with norewrite action for rewrite policy:
add audit messageaction log-act1 ALERT "\"Client:\"+CLIENT.IP.SRC+\" accessed \"+HTTP.REQ.URL" -bypassSafetyCheck YES
add rewrite policy log-rewr-pol true NOREWRITE -logAction audit_log_action
bind lb vserver <VSERVER NAME> -policyName log-rewr-pol -priority 5 - gotoPriorityExpression END -type REQUEST
Note: When binding an audit policy to a virtual server (via rewrite policy), audit server global setting "User configurable Log messages" has to be enabled.
Citrix eDocs - NetScaler 10 Audit Commands and Configuring the NetScaler Appliance for Audit Logging.