Debug Mode
#
Basic Debug ModeEnable basic debug mode via conf/debug.yaml
file:
basic: enable: true
Note: before APISIX 2.10, we enabled basic debug mode by setting apisix.enable_debug = true
in conf/config.yaml
file.
e.g Using both limit-conn
and limit-count
plugins for a /hello
request, there will have a response header called Apisix-Plugins: limit-conn, limit-count
.
$ curl http://127.0.0.1:1984/hello -iHTTP/1.1 200 OKContent-Type: text/plainTransfer-Encoding: chunkedConnection: keep-aliveApisix-Plugins: limit-conn, limit-countX-RateLimit-Limit: 2X-RateLimit-Remaining: 1Server: openresty
hello world
If the information can not be delivered via HTTP response header, for example, the plugin is in stream
subsystem, the information will be logged in the error log with warn
level.
#
Advanced Debug ModeEnable advanced debug mode by modifying the configuration in conf/debug.yaml
file. Because there will be a check every second, only the checker reads the #END
flag, and the file would be considered as closed.
The checker would judge whether the file data changed according to the last modification time of the file. If there has any change, reload it. If there was no change, skip this check. So it's hot reload for enabling or disabling advanced debug mode.
Key | Optional | Description | Default |
---|---|---|---|
hook_conf.enable | required | Enable/Disable hook debug trace. Target module function's input arguments or returned value would be printed once this option is enabled. | false |
hook_conf.name | required | The module list name of hook which has enabled debug trace. | |
hook_conf.log_level | required | Logging levels for input arguments & returned value. | warn |
hook_conf.is_print_input_args | required | Enable/Disable input arguments print. | true |
hook_conf.is_print_return_value | required | Enable/Disable returned value print. | true |
Example:
hook_conf: enable: false # Enable/Disable Hook Debug Trace name: hook_phase # The Module List Name of Hook which has enabled Debug Trace log_level: warn # Logging Levels is_print_input_args: true # Enable/Disable Input Arguments Print is_print_return_value: true # Enable/Disable Returned Value Print
hook_phase: # Module Function List, Name: hook_phase apisix: # Referenced Module Name - http_access_phase # Function Names:Array - http_header_filter_phase - http_body_filter_phase - http_log_phase#END
#
Enable Advanced Debug Mode DynamicallyThe advanced debug mode can take effect in particular requests by dynamic rule.
Example:
http_filter: enable: true # Enable/Disable Advanced Debug Mode Dynamically enable_header_name: X-APISIX-Dynamic-Debug # Trace for the request with this header......#END
Dynamically enable advanced debugging mode in a particular request like this:
curl 127.0.0.1:9090/hello --header 'X-APISIX-Dynamic-Debug: foo'
Notice: We can not hook the apisix.http_access_phase
module for particular requests, since whether the advanced debug mode is enabled is determined after these requests enter such phase.