Skip to main content
Logixlysia can accumulate context during a request and merge it into the automatic access log—similar to evlog wide events, without replacing your existing logger.info() API.

Basic usage

The final INFO access log includes a context object with userId and cartTotal (and renders as a context tree when showContextTree is enabled).

Precedence

When you call logger.info(request, message, { ...explicit }), keys in the explicit context override accumulated values. Non-colliding keys from both sources are kept.

Reading context

Request-Scoped Logger & AsyncLocalStorage

Instead of manually passing the request object to store.logger methods (e.g. store.logger.info(request, message)), you can enable AsyncLocalStorage propagation:
When enabled, a request-scoped logger log is derived automatically on the Elysia handler context. You can also retrieve the active logger globally in nested service layers or helper functions using the useLogger() hook.

1. Handler Context (log)

Destructure log directly in your route handlers:

2. Global Hook (useLogger())

Import useLogger() to log or merge context from deeply nested operations without prop-drilling the request context:

Typed Fields

userId on one route and user_id on the next is the kind of drift that makes a dashboard query quietly incomplete. Pass a field type to the plugin and TypeScript catches it at compile time:
Every field stays optional — you declare the vocabulary, not a requirement to fill it in on every route. useLogger() takes the same parameter, so context stays typed outside the handler too:
This is type-only: there is no runtime cost, and leaving the parameter off keeps every key allowed, exactly as before.