Log Levels
Control log verbosity
Control the verbosity of your logging output with Logixlysia’s log level system.
Available Levels
Logixlysia has four log levels, from most to least verbose:
DEBUG > INFO > WARNING > ERROR
logFilter.level is the list of levels to keep. It is not a minimum level, so ['WARNING'] keeps WARNING lines and drops ERROR lines. List every level you want.
Levels for request logs
Logixlysia writes each access line once, from the final response, and picks its level from the status the client received:
| Status | Level |
|---|---|
500 and above |
ERROR |
400 to 499 |
WARNING |
Below 400 |
INFO |
This includes responses from Elysia’s status() helper, whether a handler returns it, throws it, or returns it from beforeHandle:
app
.get('/missing', ({ status }) => status(404, 'Item not found'))
.post('/items', ({ status }) => {
throw status(409, { reason: 'duplicate' })
})
The first route logs a WARNING with status 404 and an empty message, because a returned status() is not an error. Only a thrown status() sets the message. A string body becomes the message, so throw status(404, 'Item not found') logs Item not found. Any other body is replaced by the status text, so the second route logs Conflict and keeps the response payload out of the log.
If a handler returns a Response, Logixlysia logs the Response status. When that status is 200, set.status applies instead.
The final status also covers a status set with set.status before a throw, a status chosen by a later onError hook, and a mapResponse rewrite. A few exits follow different rules:
- A thrown error that reached the client as a 2xx or 3xx is still an
ERRORline. This happens when anonErrorhook turns a failure into a redirect, or when a streamed body fails after the headers went out. A thrown 2xx or 3xxstatus()result is the exception. It logs atINFOas an access line, without its message. - When an app-wide
onErrorregistered before Logixlysia answers an error, Logixlysia never sees the thrown value. The line is an access line at the level of the status sent, with an empty message and no error payload. - With the plugin mounted inside
group()orguard(), anonErrorhook registered after Logixlysia that awaits before answering with another status can finish after the line is written. The line then carries the status known when it was written.
The same status drives the {status} format token, the status field sent to transports, and tail sampling.
Configuration
Single Level
logixlysia({
config: {
logFilter: {
level: ['ERROR']
}
}
})
Multiple Levels
logixlysia({
config: {
logFilter: {
level: ['INFO', 'ERROR']
}
}
})
Environment-based
logixlysia({
config: {
logFilter: {
level:
process.env.NODE_ENV === 'production'
? ['ERROR', 'WARNING']
: ['DEBUG', 'INFO', 'WARNING', 'ERROR']
}
}
})
Pino Log Levels
When using Pino integration, you can also configure Pino’s log levels:
logixlysia({
config: {
pino: {
level: 'debug' // 'fatal', 'error', 'warn', 'info', 'debug', 'trace'
}
}
})
Best Practices
- Development: keep all four levels
- Staging: keep
INFO,WARNING, andERROR - Production: keep
WARNINGandERROR - Monitoring: keep
ERRORand alert on it
Example Configurations
Development
logFilter: {
level: ['DEBUG', 'INFO', 'WARNING', 'ERROR']
}
Production
logFilter: {
level: ['WARNING', 'ERROR']
}
Monitoring
logFilter: {
level: ['ERROR']
}