logger.info() API.
Basic usage
INFO access log includes a context object with userId and cartTotal (and renders as a context tree when showContextTree is enabled).
Precedence
When you calllogger.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 therequest object to store.logger methods (e.g. store.logger.info(request, message)), you can enable AsyncLocalStorage propagation:
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:
useLogger() takes the same parameter, so context stays typed outside the handler too: