# Selective debug

**URL:** <https://community.a10networks.com/t/selective-debug/257>\
**Category:** aFleX\
**Tags:** debug\
**Created:** [February 13, 2014, 9:12am UTC](https://community.a10networks.com/t/selective-debug/257 "2014-02-13T09:12:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oj.dupuis](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@oj.dupuis](https://community.a10networks.com/u/oj.dupuis)\
**Post date:** [February 13, 2014, 9:12am UTC](https://community.a10networks.com/t/selective-debug/257/1 "2014-02-13T09:12:48Z")

</div>

Hello,

I wish to be able to make A10 add debug header informations in the response header when I add a certain header in the request. I dont want all the requests to be in debug mode, just the one I send. I ended up with this code :

when HTTP\_REQUEST {  
&nbsp;&nbsp;set ::DEBUG 0  
&nbsp;&nbsp;# detection debug  
&nbsp;&nbsp;if { [HTTP::header exists “X-Debug”] } {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log local0.DEBUG “DEBUG FORCE”  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set ::DEBUG 1

```auto
  \}
\}

when HTTP\_RESPONSE \{
  if \{ $::DEBUG == 1 \} \{
    HTTP::header insert "X-Debug-A10" "[LB::server pool] [LB::server name]"
  \}
\}

```

but this doesn’t work because of the scope of the DEBUG variable.  
If I add the DEBUG variable to the HTTP\_INIT event, it’s scope becomes global to the aflex and all the subsequent requests are treated in DEBUG mode.  
How could I achieve this ?

Thanks for your help,

Olivier

---

<div class="post-metadata">

**Author:** ![oj.dupuis](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@oj.dupuis](https://community.a10networks.com/u/oj.dupuis)\
**Post date:** [February 13, 2014, 9:15am UTC](https://community.a10networks.com/t/selective-debug/257/2 "2014-02-13T09:15:48Z")

</div>

instead of HTTP\_INIT I meant RULE\_INIT…

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [February 18, 2014, 9:49pm UTC](https://community.a10networks.com/t/selective-debug/257/3 "2014-02-18T21:49:11Z")

</div>

Try something like the following:  
`when RULE_INIT {`  
`set ::DEBUG 0`  
`}

when HTTP\_REQUEST { # detection debug if { [HTTP::header exists “X-Debug”] } { log local0.DEBUG “DEBUG FORCE” set ::DEBUG 1 } }

when HTTP\_RESPONSE { if { $::DEBUG == 1 } { HTTP::header insert “X-Debug-A10” “[LB::server pool] [LB::server name]” set ::DEBUG 0 } }`
