Troubleshooting protocol extensions

If your extension function is not behaving as expected, you can use extension tracing functionality to verify the behavior of your extension function. You can also add logging to your extension function by using the custom logging functionality, where you can define the log level to be captured on the Citrix ADC appliance.

Custom logging

You can also add your own logging to your extension function. To do so, use the built-in ns.logger:level() function, where level is emergency , alert , critical , error , warning , notice , info , or debug . The parameters are the same as the C printf() function: a format string, and a variable number of arguments to supply values for the % specified in the format string. For example, you might add the following to the COMBINE_HEADERS function to log the result of a call:

local result\_str = table.concat(combined\_headers, "\\r\\n") .. "\\r\\n\\r\\n"

ns.logger:info("Result: %s", result\_str)

return result\_str
<!--NeedCopy-->

The above function would log the following message to/var/log/ns.log for the sample input shown in the abbreviated log messages examples in the Extension Tracing section above.

... : default NSEXTENSION Message 143 0 : "Result: Host: 10.217.24.7:2000^M H1: abcd, 1234^M User-Agent: curl/7.24.0 (amd64-portbld-freebsd8.4) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.3^M Accept: \*/\*^M H2: h2val1, h2val2, h2val3^M ^M"

Troubleshooting protocol extensions