# Logging

`connection::async_run` is a complex algorithm, with features like built-in reconnection. This can make configuration problems, like a misconfigured hostname, difficult to debug - Boost.Redis will keep retrying to connect to the same hostname over and over. For this reason, Boost.Redis incorporates a lightweight logging solution, and will log some status messages to stderr by default.

Logging can be customized by passing a `logger` object to the connection’s constructor. For example, logging can be disabled by writing:

    asio::io_context ioc;
    connection conn {ioc, logger{logger::level::disabled}};

Every message logged by the library is attached a syslog-like severity tag (a `logger::level`). You can filter messages by severity by creating a `logger` with a specific level:

    asio::io_context ioc;

    // Logs to stderr messages with severity >= level::error.
    // This will hide all informational output.
    connection conn {ioc, logger{logger::level::error}};

The `logger` constructor accepts a `std::function<void(logger::level, std::string_view)>` as second argument. If supplied, Boost.Redis will call this function when logging instead of printing to stderr. This can be used to integrate third-party logging libraries. See our spdlog integration example for sample code.