Attention! Helicon Tech Blog has moved to

Friday, June 5, 2009

Web application debugging with mod_developer


Helicon Ape mod_developer is the module designed to debug web applications running on IIS. The module will be useful for developers who are actively using Helicon Ape (for example, mod_rewrite module), and all other IIS or ASP.NET developers.
mod_developer provides debug information about each HTTP-request: HTTP request and response headers, server variables, querystring and forms values, cookies and sessions data. The module can provide detailed information about other Helicon Ape modules operation, e.g. about mod_rewrite: involved maps, applied RewriteRule and RewriteCond directives.
mod_developer can work in two modes: as «embedded into html page» or as «request logger in frame».

Embedding into HTML page

This mode is useful if you need to debug HTML pages processing (i.e. HTTP responses from the server with Content-Type: text/html or text/xhtml). To enable mod_developer do not forget to uncomment the following lines in httpd.conf:
LoadModule env_module         modules/
LoadModule developer_module   modules/
and put this line into .htaccess near debugging file:
SetEnv mod_developer_enable
or web site root .htaccess if you want to debug all site HTML pages.

Warning! mod_developer was designed to debug web applications and we strongly recommended not to enable it on production servers, as this may greatly affect the server performance and can corrupt HTML pages markup.
After enabling the module, go to some page on the site. In the upper left corner you'll see «show» button that toggles debug information toolbar.

Request Logger in Frame

This mode makes it possible to get debugging information not only for HTML pages, but also for any other requests (Content-Type should not necessarily be text/html). In this case the page is divided into two frames. The bottom frame shows the site and the top frame shows (and periodically updates) the log of all processed requests with corresponding debug information.
To enable this mode put this line into your .htaccess:
SetEnv mod_developer_enable_logger
Then you should point your browser to http://yoursite/_ape_embedded_/mod_developer/request_logger.html

Enter the URL you want to debug in the top frame and request it. In the bottom frame you'll get request resource, and the top frame will present all requests that are processed by the server.

Click on a specific request line to see debug information.



As we already noticed in «Embedding into HTML page» section, we do not recommend to enable mod_developer on production server. It may affect server performance; request log will grow up to enormous size and it will be kept up to date a large number of queries.
In «Embedding into HTML page» mode mod_developer will only work if html page has </body> closing tag as the module inserts its debugging data before this tag.
It is recommended to run only one instance of /_ape_embedded_/mod_developer/request_logger.html. It receives information about processed requests from the server, and if you have more than one such page, they will share debugging information among themselves in an unpredictable way.
Note! Request logger shows information only for requests processed in the same application pool where mod_developer_enable_logger environment variable was defined.

No comments:

Post a Comment