Output Formats
2 minute read
Source: pinned upstream
README.md, sections “Binary Format” and “JSON Format”, plus the generated command reference.
pgBadger selects output from the filename extension or from -x / --extension. Use -o / --outfile more than once to create multiple formats from the same parse.
| Format | Typical extension | Best use |
|---|---|---|
| HTML | .html |
interactive, human-readable report with charts |
| Text | .txt |
terminal review and plain archival output |
| Binary | .bin |
mergeable intermediate statistics and report rebuilds |
| JSON | .json |
integration with other software; requires JSON::XS |
| Raw CSV | chosen output file | row-oriented extraction with --dump-raw-csv |
HTML and text
The default output is out.html:
HTML normally embeds the scripts, styles, fonts, and report data needed for standalone viewing. -X / --extra-files moves shared JavaScript and CSS out of incremental reports; keep those assets beside the HTML tree.
Generate text explicitly:
Use - as the output filename to write a supported format to standard output.
Binary intermediate data
Binary output separates parsing from presentation. Generate hourly increments from one growing daily log:
Merge one or more binary files into a fresh report:
When the server writes one log file per hour, create one binary file for each rotation, then rebuild the cumulative HTML whenever required:
Keep binary files from compatible pgBadger versions together. Read the release notes for incremental-format compatibility before upgrading a long-lived report directory.
JSON
JSON output is intended for programmatic consumers such as monitoring or reporting pipelines:
Install JSON::XS first. Add --prettify-json for readability when file size and generation time are secondary.
Raw and query-oriented exports
The command reference also provides specialized exports:
--dump-raw-csvparses the log and writes row-oriented CSV without building a report;--csv-separatorchanges the raw CSV delimiter;--dump-all-queriesemits every query after replacing bind parameters;--normalized-onlywrites normalized queries;--query-numberingnumbers query-oriented text output.
These modes may contain application SQL, identifiers, users, client addresses, or literal values. Review the output before sharing it and use --anonymize when the intended analysis does not require literals.