Skip to content

How to Configure HAProxy Logging and Log Format

DodaTech Updated 2026-06-24 2 min read

HAProxy logging captures critical information about traffic flows. Custom log formats extract exactly the data needed for analysis. This guide walks through the specific troubleshooting steps to diagnose and resolve logging configuration issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

log /dev/log local0 (default log format)

Wrong: Default logging without customization

log /dev/log local0\noption httplog\nlog-format %ci\ %cp\ %fi\ %fp\ %t\ %ST\ %B\ %s

Right: Custom log format with client IP, port, and timing

Output

HAProxy logging configured\n  Format: custom (client IP, port, timestamps, status)\n  Facility: local0\n  Option: httplog

Prevention

To avoid future issues, follow these best practices:

  • Use option httplog for detailed HTTP request logging
  • Customize with log-format for specific data fields
  • Log client IP (%ci), timestamps (%t), status (%ST), and bytes (%B)
  • Use separate log files for frontend and backend
  • Use log global in frontend/backend to inherit global settings

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with log format

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world HAPROXY code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What log fields are available in HAProxy?|||Hundreds of fields: client IP (%ci), server IP (%si), timestamps (%t, %Tq, %Tw, %Tc, %Tr), status (%ST), bytes (%B), headers, cookies, etc.
How do I send HAProxy logs to a remote syslog server? Configure log server_ip:port len facility in global section. Add @ to use UDP or @@ for TCP syslog.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro