✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: December 13, 2025
  • 7 min read

LogTape‑Fedify Case Study: Unobtrusive Structured Logging for Modern Applications

LogTape’s integration with Fedify shows that hierarchical categories, zero‑default output, and automatic request‑ID tracing can turn a normally noisy logging library into an unobtrusive, production‑ready observability tool.

Illustration of LogTape and Fedify working together
Visual representation of LogTape’s hierarchical logging model in the Fedify framework.

LogTape‑Fedify Case Study: Structured Logging for Unobtrusive Libraries

The LogTape‑Fedify case study demonstrates how a modern JavaScript logging library can solve the long‑standing problem of noisy logs in reusable libraries. Fedify, an ActivityPub server framework, needed a logging solution that would stay silent by default yet become highly visible when developers required insight. LogTape delivered exactly that, offering hierarchical logging categories, zero default output, and request‑ID tracing that works across async boundaries.

In this article we break down the challenges, explore LogTape’s core features, walk through real‑world configuration for Fedify, and extract actionable lessons for any developer building a library that must coexist peacefully with its host application.

Background: Logging Challenges in Library Code

Traditional logging frameworks such as Winston, Pino, or Bunyan assume the consumer is an application. They emit logs to the console or a file as soon as they are instantiated, which is perfect for end‑user services but problematic for reusable libraries. Library authors face a dilemma:

  • Too much output clutters the host application’s logs, making it hard for users to spot their own messages.
  • Too little output leaves developers blind to internal failures, turning debugging into guesswork.
  • Most loggers rely on global configuration or environment variables, which can be restricted in sandboxed runtimes (e.g., Deno).
  • Correlating logs across asynchronous calls is difficult without manually passing context objects.

Fedify’s developers quickly realized that none of the existing solutions satisfied the “quiet‑by‑default, loud‑when‑asked” requirement. This gap inspired the creation of LogTape, a library built from the ground up for library authors.

LogTape Features That Solve the Problem

Hierarchical Logging Categories

LogTape introduces a tree‑like namespace for log messages. Each node represents a subsystem, and developers can enable or silence any branch independently. For Fedify the hierarchy looks like:

Category Path What It Logs
["fedify"] All library‑wide events
["fedify","federation","inbox"] Incoming ActivityPub activities
["fedify","federation","outbox"] Outgoing activities and deliveries
["fedify","federation","http"] Raw HTTP request/response cycles
["fedify","sig","http"] HTTP Signature generation and verification
["fedify","runtime","docloader"] JSON‑LD document loading

By exposing this hierarchy, a developer can enable debug level logs only for ["fedify","federation","inbox"] while keeping the rest silent, achieving laser‑focused visibility.

Zero Default Output

Unlike most loggers that emit at least an info level by default, LogTape’s sinks are inert until the host application explicitly registers them. This design guarantees that a library never pollutes a user’s console out‑of‑the‑box, preserving performance and respecting the “no‑surprise” principle.

Automatic Request‑ID Tracing with Implicit Contexts

Correlating logs across asynchronous calls is essential for federated protocols where a single request spawns many background tasks. LogTape leverages AsyncLocalStorage (or its Deno equivalent) to attach a requestId to every log entry automatically. The ID is derived from standard headers (X‑Request‑Id, Traceparent) when present, otherwise a UUID is generated.

The result is a single, searchable field that lets operators filter an entire request’s lifecycle with a command such as:

jq 'select(.properties.requestId == "abc-123")' fedify.jsonl

No manual propagation of context objects is required, dramatically reducing boilerplate and the risk of lost correlation.

Implementation Details and Configuration Examples for Fedify

Integrating LogTape into Fedify required only a few lines of setup code. Below is a minimal configuration that demonstrates each of LogTape’s core capabilities.

Step 1: Install LogTape

npm install @logtape/core

Step 2: Create Sinks

Sinks define where logs are written. In this example we use a console sink for development and a JSON‑Lines file sink for production observability.

import { createConsoleSink, createFileSink } from '@logtape/sinks';

const consoleSink = createConsoleSink({ pretty: true });
const fileSink = createFileSink('fedify.jsonl', { formatter: 'jsonl' });

Step 3: Register Hierarchical Loggers

The following configuration enables error level logs for the entire library while turning on debug for the inbox subsystem only.

import { configure } from '@logtape/core';
import { AsyncLocalStorage } from 'async_hooks';

await configure({
  sinks: {
    console: consoleSink,
    file: fileSink,
  },
  loggers: [
    {
      category: 'fedify',
      sinks: ['file'],
      lowestLevel: 'error',
    },
    {
      category: ['fedify', 'federation', 'inbox'],
      sinks: ['console'],
      lowestLevel: 'debug',
    },
  ],
  contextLocalStorage: new AsyncLocalStorage(),
});

Step 4: Emit Logs in Fedify Code

With the configuration in place, logging calls become no‑ops unless a matching sink is active. Example from the HTTP handler:

import { getLogger } from '@logtape/core';

const httpLogger = getLogger(['fedify', 'federation', 'http']);

async function handleRequest(req) {
  httpLogger.debug('Incoming request', { method: req.method, url: req.url });
  // ...process request...
  httpLogger.info('Response sent', { status: 200 });
}

When the application does not register any sinks, these calls incur virtually no runtime cost, satisfying the “unobtrusive” requirement.

Lessons Learned and Best Practices for Unobtrusive Structured Logging

  • Design the hierarchy early. Map categories to logical subsystems before writing code; retro‑fitting later leads to fragmented logs.
  • Prefer structured over string interpolation. Key‑value pairs (e.g., {requestId, activityId}) enable powerful downstream analysis.
  • Make logging opt‑in. Zero default output respects the host application’s logging policy and eliminates unwanted noise.
  • Leverage implicit contexts. Automatic request‑ID propagation removes the need for manual context passing, especially in async‑heavy environments.
  • Provide sane defaults for production. Ship a JSON‑Lines sink that integrates with common log aggregators (e.g., Loki, Elastic) while keeping the console silent.
  • Document the API clearly. Users should be able to enable a single category with a one‑line config, as shown above.
  • Test performance impact. Benchmark the no‑op path; LogTape’s design ensures sub‑microsecond overhead when sinks are disabled.

These practices not only improve developer experience but also align with modern observability stacks that expect JSON‑structured, correlated logs.

Related UBOS Resources for Developers

If you’re interested in extending the concepts from this case study to other parts of your stack, UBOS offers a suite of tools that complement structured logging:

Conclusion

The LogTape‑Fedify case study proves that a well‑designed logging library can be both invisible and indispensable. By embracing hierarchical categories, zero default output, and automatic request‑ID tracing, developers gain fine‑grained observability without sacrificing the clean‑room experience that library users expect.

Ready to bring the same level of control to your own projects? Explore the UBOS homepage for a free trial, or dive straight into the UBOS portfolio examples to see structured logging in production.

Whether you are building a startup SDK, an enterprise‑grade microservice, or a hobbyist library, the principles outlined here will help you deliver logs that empower, not overwhelm, your users.

Read the original source here.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.