How to choose a logging framework: eight checks from app to collector
Compare logging frameworks across eight dimensions, including output schema, context, exceptions, backpressure and sampling. Check the same records at the collector.
A checkout alert goes quiet after a logger upgrade. The service still emits error records, but a filter expects ERROR where the new output uses a number. Or the application writes an exception as several lines and the collector stores each stack frame separately. The library can work as designed while the path from the application to the alert breaks.
Choose a logging framework by following that whole path. Use a normal request, a failed request with an exception, and a burst of output. The same records will help you compare eight things, from the application API to what your team can maintain.
What the application writes
1. Level and filtering
Check how the framework represents severity and where it filters records. A numeric logger level, a string such as ERROR, and an HTTP response code serve different purposes. Make sure the filter can select the records your team needs. When expensive arguments are built before a disabled log call, the application can still pay to compute them. Go slog documentation
2. Structured output
Choose a format the collector can parse. JSON works well when the application writes one object per line and preserves field types. A development formatter can favor readability. Agree on names and types for event time, severity, and diagnostic fields, then compare what is actually written. A number encoded as a string can change a range query.
3. Context propagation
Separate process attributes from fields that belong to a request or event. A child logger or a context adapter can carry a service or request field, but check that the value follows background work and clears between requests. Record a real trace ID when a trace context is available. In Guance trace details, the whole-trace log view uses trace_id; the index mapping can use service, env, and version. The related logs also need to be collected and accessible. Guance trace details
4. Exceptions
Pass the actual exception to the framework using its supported API. Inspect the output for the fields your team needs, such as the error type, message, and stack. A stack with escaped newlines fits inside one JSON record. If the logger writes a text stack on several lines, configure the collector's multiline rule and check where one event ends and the next begins. DataKit log collection
What happens under load
5. Write cost and backpressure
Measure comparable events at representative rates with the output you will run. A discard sink can isolate encoding costs, while a real file or stream exposes write delays. An asynchronous queue can move some work off the request thread. When it fills, the configured policy can block, discard, or handle the work synchronously. Check memory, request latency, losses, and how the queue drains at shutdown. Log4j 2 asynchronous logging · Python QueueHandler
6. Sampling and filtering
Decide which records you can afford to lose and where to reduce them. Sampling retains part of a stream. A filter keeps records that satisfy a condition. Put required error and audit records outside an optional sampling rule, and verify that the remaining records still support your alerts. A sampled event count needs its sampling context to estimate the original volume.
7. Effects on the application and tests
Test a slow or unavailable destination and an unencodable field. Some logger methods can terminate the process, so check the API before replacing a normal error call with a fatal one. Use an in-memory sink in tests to verify the emitted record and failure behavior. Compare how the application behaves with logging enabled, disabled, and backed up.
What your team can maintain
8. Runtime support and ecosystem
Check the exact runtime version, dependencies, release and security history, and framework integration. In Java, confirm the SLF4J provider present at runtime. In PHP, match the PSR-3 package version. A familiar library with a well-understood output path can take less work to operate than a larger one.
| Runtime | A sensible place to start | Boundary to check |
|---|---|---|
| Node.js | Pino for JSON output | Child logger fields and the chosen destination or transport |
| Go | slog in Go 1.21+, or a library such as Zap or Zerolog | Handler or writer, output field names, and the real cost under load |
| Java | SLF4J with a compatible provider, such as Logback or Log4j 2 | The active provider and the configured appenders |
| Python | logging, with a formatter and handlers, or an option such as structlog or Loguru | Where formatting runs, how context moves, and how any queue is drained |
| PHP | Monolog behind PSR-3 | The actual handler, formatter, and output |
| Ruby | Logger for a simple sink, or Semantic Logger for structured payloads and appenders | Output format, queue policy, and flush behavior |
Check the record at the collector
In a local Python 3.13.1 fixture, a custom formatter wrote a synthetic checkout error as one JSON line. It kept level as the string ERROR, kept http_status_code as the number 503, and encoded the exception with escaped newlines. A separate queue with room for one record, a QueueHandler, and no consumer retained the first record. The second hit the handler's error path. That exercise checks output shape and queue saturation.
For the real service, collect the configured container stream or file in DataKit. Run both a normal line and an error through Guance Pipeline. Verify that event time lands where you expect, severity maps to status, and the HTTP code stays numeric in its own field. For network delivery, match the sender and receiver's protocol and encoding, then check the retry and buffering behavior. Run the existing alert query against a test source before switching the output. Guance Pipeline quick start
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan
