**Low Frontend Latency**
The calling thread only encodes and queues the log arguments. See the
[latency benchmarks](https://quillcpp.readthedocs.io/en/latest/benchmarks_latency.html) for measured results and
methodology.
|
**Deferred Formatting**
The backend worker does the expensive formatting, not the calling thread.
|
**High Backend Throughput**
A single backend thread formats and writes millions of messages per second to files,
the console and custom sinks. See the [throughput benchmarks](https://quillcpp.readthedocs.io/en/latest/benchmarks_throughput.html).
|
**Fast to Compile**
Files that log include only `Logger.h` and `LogMacros.h`, two headers with minimal dependencies. Log statements
with the same argument types share their code, and the backend is compiled in a single `.cpp` file of your own, not
in the files that log. See the
[compilation time benchmark](https://quillcpp.readthedocs.io/en/latest/benchmarks_compile_time.html).
|
**Logs, Metrics and Data Files**
The same asynchronous backend that writes your logs also publishes pre-registered
[metrics](https://quillcpp.readthedocs.io/en/latest/metrics.html), through the bundled Prometheus sink or a sink of
your own. It also writes [CSV files](https://quillcpp.readthedocs.io/en/latest/csv_writing.html), records
[raw data](https://quillcpp.readthedocs.io/en/latest/binary_protocols.html#raw-binary-file-writing) such as a market
data feed to files as it arrives, and writes
[packet captures](https://quillcpp.readthedocs.io/en/latest/binary_protocols.html#writing-pcap-files) that Wireshark
and tcpdump can open. See the [Use Cases](#-use-cases) for an example of each.
|
**Highly Customizable**
Choose frontend queues and memory policy at compile time; set backend idle behaviour, CPU affinity, buffering,
timestamp handling, flushing, and callbacks at runtime; and compose loggers from built-in or custom sinks with
per-sink filters. See
[Frontend Options](https://quillcpp.readthedocs.io/en/latest/frontend_options.html),
[Backend Options](https://quillcpp.readthedocs.io/en/latest/backend_options.html), and
[Sinks](https://quillcpp.readthedocs.io/en/latest/sinks.html).
|
**Production-Focused Testing**
Continuously tested across Linux, macOS, Windows, and BSD, with sanitizers and fuzzing.
|
> Using Quill? Click **Star** at the top of the [GitHub repository](https://github.com/odygrd/quill) to help other C++
> developers discover it.
---
## 🧰 Use Cases
**One backend thread for your logs, metrics, data files and packet captures.**
By default, every call below costs your thread one thing: encoding its arguments into a lock-free queue of its own,
which for most types is a plain copy. The backend thread formats, merges everything in timestamp order across all
threads and does the I/O, so where a record goes, to a file, a terminal or a metrics collector, does not change what
it costs your thread.
| Use Quill to | Your thread calls | The backend thread writes |
|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------|:------------------------------------------------------------------------------------------------|
| Log [text](https://quillcpp.readthedocs.io/en/latest/sink_types.html) to the console, to files rotated by size or time, or to syslog, the systemd journal and Android logcat | `LOG_INFO(logger, "User {} logged in from {}", user, address);` | `User alice logged in from 10.0.0.5`, with the time, thread and source location of your pattern |
| Write structured [JSON](https://quillcpp.readthedocs.io/en/latest/json_logging.html) logs, for a log pipeline to search | `LOGJ_INFO(logger, "User logged in", user, address);` | `{…,"user":"alice","address":"10.0.0.5"}` |
| Log [your own types](https://quillcpp.readthedocs.io/en/latest/recipes.html#logging-user-defined-types) with the formatter they already have | `LOG_INFO(logger, "Connected to {}", endpoint);` | `Connected to example.org:443` |
| Publish [metrics](https://quillcpp.readthedocs.io/en/latest/metrics.html) to any metrics system, with a built-in sink for Prometheus | `METRIC(metrics_logger, requests_total, 1.0);` | Each sample to your metrics sink, e.g. `requests_total 1024` for Prometheus |
| Write [CSV files](https://quillcpp.readthedocs.io/en/latest/csv_writing.html) | `weather_csv.append_row("Athens", 21.4, 40);` | `Athens,21.4,40`, below the header `city,temperature,humidity` of every file |
| Record [binary data](https://quillcpp.readthedocs.io/en/latest/binary_protocols.html#raw-binary-file-writing) as it arrives, such as a sensor stream or a market data feed | `LOG_BINARY(logger, &reading, sizeof(reading));` | The bytes as they are, or after their size and timestamp |
| Capture [network traffic](https://quillcpp.readthedocs.io/en/latest/binary_protocols.html#writing-pcap-files) | `pcap_writer.write_packet(frame, frame_size, timestamp_ns);` | A capture that Wireshark and tcpdump open, in a new file every hour if you like |
| Decode [binary protocols](https://quillcpp.readthedocs.io/en/latest/binary_protocols.html) such as SBE into readable text | `LOG_INFO(logger, "[IN] {}", SbeMessage{buffer, size});` | The fields of each message, decoded on the backend thread |
| Send records [anywhere](https://quillcpp.readthedocs.io/en/latest/sinks.html): a database, a socket, a message bus | A sink of your own, with `write_log(LogRecord const&)` | Whatever your sink does with each record |
---
## ⏩ Quick Start
### Installation
Install Quill with the package manager of your choice:
| Package Manager | Installation Command |
|:---------------:|:----------------------------------------------:|
| vcpkg | `vcpkg install quill` |
| Conan | `conan install quill` |
| Homebrew | `brew install quill` |
| Meson WrapDB | `meson wrap install quill` |
| Conda | `conda install -c conda-forge quill` |
| Bzlmod | `bazel_dep(name = "quill", version = "x.y.z")` |
| xmake | `xrepo install quill` |
| nix | `nix-shell -p quill-log` |
| build2 | `libquill` |
### Setup
#### Quickest Setup
For the shortest path from zero to working logs, use `simple_logger()`:
```c++
#include "quill/SimpleSetup.h"
#include "quill/LogMacros.h"
int main()
{
// log to the console
auto* logger = quill::simple_logger();
LOG_INFO(logger, "Hello from {}!", "Quill");
// log to a file
auto* logger2 = quill::simple_logger("test.log");
LOG_WARNING(logger2, "This message goes to a file");
}
```
**Console output:**
```
20:07:18.423476231 [48917] main.cpp:8 LOG_INFO Hello from Quill!
```