# perldoc > DBI::ProfileDumper::Apache

---
type: CommandReference
command: DBI::ProfileDumper::Apache
mode: perldoc
section: ''
source: perldoc
---

## Quick Reference
- `PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache` — Enable profiling in Apache config
- `dbiprof /path/to/logs/dbi.prof.*` — Generate merged report from profile files
- `$dbh->{Profile} = "2/DBI::ProfileDumper::Apache"` — Set profile attribute on a DBI handle
- `PerlSetEnv DBI_PROFILE_APACHE_LOG_DIR /server_root/logs` — Set custom log directory
- `PerlOptions +GlobalRequest` — Required for mod_perl2
- `$dbh->{Profile}->flush_to_disk()` — Free memory by writing current data to disk
- `rm /usr/local/apache/logs/dbi.prof.*` — Clean up old profile files before new run

## Name
capture DBI profiling data from Apache/mod_perl

## Synopsis
shell
# Add this line to your httpd.conf:
PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache
Then restart Apache, access the code to test, then shut down the server. This creates `dbi.prof.*` files in the Apache log directory. Generate a report with:

shell
dbiprof /path/to/your/apache/logs/dbi.prof.*
Delete the old files before each new profiling run.

When using mod_perl2, you must either set the `DBI_PROFILE_APACHE_LOG_DIR` environment variable or enable `PerlOptions +GlobalRequest` in the global config section.

## Options
- `Dir` — Destination directory for profile files (used like `File` in [DBI::ProfileDumper](http://localhost/phpMan.php/perldoc/DBI%3A%3AProfileDumper/markdown))
- `Quiet` — Set to true to suppress log messages when `flush_to_disk()` is called (e.g., `PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache/Quiet:1`)
- `DBI_PROFILE_APACHE_LOG_DIR` — Environment variable to override the default log directory (e.g., `PerlSetEnv DBI_PROFILE_APACHE_LOG_DIR /server_root/logs`)
- `PerlOptions +GlobalRequest` — Required under mod_perl2 to access the global `$r` object; otherwise an error is logged

**Default filename**: `dbi.prof.PPID.CPID` (parent PID and child PID appended)

## Examples
**Loading via environment variable in httpd.conf:**
perl
PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache
**Loading via DBI handle attribute:**
perl
$dbh->{Profile} = "2/DBI::ProfileDumper::Apache";
**Custom directory and quiet mode:**
perl
$dbh->{Profile} = "!Statement/DBI::ProfileDumper/Quiet:1";
**Flushing data to free memory (e.g., every 100 requests):**
perl
$dbh->{Profile}->flush_to_disk()
    if $dbh->{Profile} and ++$i % 100;
**Generating a report from multiple profile files:**
shell
dbiprof /usr/local/apache/logs/dbi.prof.2604.*
## See Also
- [DBI::ProfileDumper](http://localhost/phpMan.php/perldoc/DBI%3A%3AProfileDumper/markdown) — base class for profile data dumping
- [DBI::Profile](http://localhost/phpMan.php/perldoc/DBI%3A%3AProfile/markdown) — detailed documentation of the DBI profiling mechanism
- `dbiprof` — command-line tool to analyze profile files

## Exit Codes
Not documented.