Configuration
Complete configuration reference for Logixlysia
Complete reference for all Logixlysia configuration options.
Configuration Object
All configuration options are passed through the config property:
logixlysia({
preset: 'prod', // optional: 'dev' | 'prod' | 'json'
config: {
// ... configuration options (override preset)
}
})
See Presets for defaults per environment.
Startup Options
showStartupMessage
Whether to display the startup message when the server starts.
- Type:
boolean - Default:
true
showStartupMessage: true
startupMessageFormat
Format of the startup message.
- Type:
'simple' | 'banner' - Default:
'banner'
startupMessageFormat: 'simple' // or 'banner'
Display Options
useColors
Enable colored output in console logs.
- Type:
boolean - Default:
true
useColors: true
Colors require an interactive terminal: when stdout is not a TTY (Docker, CI, or output piped to a file), logs are printed uncolored even with useColors: true. The same holds when the NO_COLOR environment variable is set to a non-empty value. On Node.js before 22.12, which cannot require an ES module, terminal lines are also printed uncolored.
ip
Makes the {ip} placeholder of customLogFormat print the client IP. The default format has no {ip}, so ip: true alone changes nothing. The IP is not added to JSON output or to the record transports receive.
- Type:
boolean - Default:
false
ip: true,
customLogFormat: '{now} {level} {ip} {method} {pathname} {status}'
How IP is resolved: The client IP is read from HTTP headers in this order:
x-forwarded-for— uses the first (leftmost) IP in the comma-separated list (the original client when behind proxies)x-real-ip— fallback whenx-forwarded-foris not present
Both headers are set by whoever sends the request unless a proxy in front of the app overwrites them, so treat the value as a hint for dashboards, not as an identity.
These headers are typically set by reverse proxies (nginx, Caddy, Cloudflare, etc.) and load balancers. When testing locally (localhost or LAN) without a proxy, these headers are usually absent, so the {ip} placeholder will be empty. To test IP logging locally, you can pass a header manually, e.g. curl -H 'x-real-ip: 1.2.3.4' http://localhost:3000/.
autoRedact
Automatically redacts sensitive data from log messages, context objects, errors, and request headers before they are outputted. Redaction runs in three ways:
-
By key/header name — a built-in, case-insensitive denylist (
authorization,cookie,x-api-key,password,secret,token,session, and more) wholly redacts the value of any matching object key or request header, regardless of what the value looks like.-,_, and camelCase variants (x-api-key,x_api_key,xApiKey) all match.Keys ending in
api-key,access-key,private-key, orsigning-keyunder any prefix are always masked. For example,x-goog-api-key,stripeApiKey, andaccessKeymatch. Keys containing anauthorizationorjwtpart are also always masked. A barekeypart is not sensitive, socache-keyandidempotency-keykeep their values. -
By value pattern — emails, IP addresses, Luhn-valid payment card numbers, JWTs, the password part of a URL, and
Bearer/Basiccredentials are redacted wherever they appear in strings, even in fields not covered by the key denylist. -
Through
toJSON— a value with atoJSONmethod (Bun’sCookieMap, your own classes) is redacted as what it serializes to. Errors keep their class.
Redaction also applies inside Headers, URL, URLSearchParams, Map, and Set values, not only plain objects and arrays.
The query of a URL in a referer, location or content-location header is checked by key like a request URL. This applies to a relative URL such as /callback?token=abc as well as an absolute one. Values nested deeper than 64 levels are replaced by "[Depth]", and a value whose toJSON throws by "[Unserializable]".
Value-pattern redaction is best-effort — it only catches values matching those specific shapes. Always prefer key-based redaction (redactKeys) for known sensitive fields instead of relying on their value happening to match a pattern. For free-text PII that has no fixed shape — names, street addresses, phone numbers, national IDs — see neural PII redaction, which runs an on-device model over records on their way to a transport.
store.pino is masked differently. With autoRedact on, the object you pass as the first argument to a store.pino call, or to a call on one of its child loggers, is masked by key name with the rule in point 1 and redactKeys, at any depth: a matching key is masked whatever its value is, unless the value is undefined, which prints nothing. The walk goes through plain data only: an object, or an array inside the logged object, that has the default prototype, no getter or setter among its own properties and no toJSON function. It does not look inside anything else: a class instance, an error, a Map, an object with a getter or a toJSON function, or an array passed as the first argument. A top-level key that has a pino serializer is handed to the serializer as you logged it. Child bindings, pino.base and the fields a mixin adds are not key-masked either. For all of those only pino’s path redaction applies: the built-in key names and redactKeys entries as written, at the top level of the line and one level below. Value patterns and redactPatterns don’t run on store.pino. Setting pino.redact turns all of this off and masks your paths instead.
- Type:
boolean - Default:
false
autoRedact: true
redactKeys
Additional key/header names to redact when autoRedact is enabled, extending the built-in denylist. Matching is case-insensitive and normalizes -, _, and camelCase variants. The same key-name matching also applies to query-string parameter names. Transports receive the request URL without its query string unless logQueryParams is true. When it is, sensitive query parameters in request.url are masked by name.
Keys containing the whole word password, passwd, or secret, or ending in token, are always sensitive, whether written in camelCase, snake_case, or kebab-case. For example, newPassword and X-CSRF-Token match. tokenizer and maxTokens don’t.
- Type:
string[] - Default:
undefined
A value that is not an array, or an entry that is not a string, makes the plugin throw logixlysia: invalid redactKeys config when you construct it. The message names the offending entry by index, such as redactKeys[1] must be a string, got number.
autoRedact: true,
redactKeys: ['x-internal-token', 'customerSsn']
redactPatterns
Extra value shapes to mask when autoRedact is enabled, for ids that only you know the shape of, such as a customer id or a national ID. Each match is replaced with [REDACTED], before the built-in value patterns run.
A pattern runs on every string a record carries, and on each URL path segment, each decoded query value and each header value, so a pattern cannot span a /. Numbers and object keys are not scanned. It does not apply to store.pino: plain objects logged there are masked by key name, and the rest by pino’s path redaction. A pattern runs on every string of every record, so keep it simple.
Patterns are made global and non-sticky for you. A pattern that can match nothing, such as /x*/ or /\b/, is rejected at startup, as is a list without autoRedact: true.
- Type:
RegExp[] - Default:
undefined
autoRedact: true,
redactPatterns: [/cust_[a-z0-9]+/]
logErrorPayload
Add the submitted value and the list of failures to the record of a failed validation, as error.found and error.errors. Each entry in errors keeps only the failure’s path and message. Both fields are on the structured record: the JSON console line (consoleFormat: 'json') and what transports receive. The text console line and the text file line show the summary only. A file written with fileFormat: 'json' holds the structured record, so it carries both fields to disk. The line’s message is a summary such as Validation failed (body): /password whether this option is on or off. Off by default, because found is the whole value that failed validation, such as the request body, and request bodies routinely carry passwords, tokens and card fields. With autoRedact on, sensitive keys such as password inside found are masked, and every failure’s message is replaced by [REDACTED], because a validator’s message can quote what was submitted. Turn autoRedact off to read the messages. A value that is not under a sensitive key is not masked by key: a body that is a bare string, the entries of an array of strings, or a field whose name the key rule does not recognise. The built-in value patterns still mask an email, a token and the like. A failure’s path and the summary message are logged on both settings and are not masked by key: a path is made of field names, but for a schema that validates a map with submitted keys (t.Record), a submitted key can be a segment of it. found is masked the way any logged value is, so a value the redactor cannot look inside, such as a FormData under Node, is passed to transports as it is.
- Type:
boolean - Default:
false
logErrorPayload: true
logQueryParams
Include query parameters in the logged URL path. Applies to the console path, the file path and the request.url transports receive.
- Type:
boolean - Default:
false
logQueryParams: true
Timestamp Options
timestamp
Timestamp configuration for the {now} console token.
- Type:
{ translateTime?: string } - Default:
undefined
Without a timestamp option or a customLogFormat, the default line prints local HH:MM:ss.SSS (for example 09:05:07.042) when stdout is a TTY, and the full ISO timestamp in UTC (2026-11-12T09:05:07.042Z) when it is not. Setting either option, even timestamp: {}, turns the short form off.
translateTime accepts three forms:
-
A bare token pattern (
yyyy,mm,dd,HH,MM,ss,SSS), rendered with local time:timestamp: { translateTime: 'yyyy-mm-dd HH:MM:ss' } -
pino-pretty’s
SYS:prefix, also local time —SYS:standardexpands toyyyy-mm-dd HH:MM:ss.SSS, or supply your own pattern after the prefix:timestamp: { translateTime: 'SYS:standard' } -
pino-pretty’s
UTC:prefix, rendered with UTC getters instead of local time:timestamp: { translateTime: 'UTC:yyyy-mm-dd HH:MM:ss' }
With pino.prettyPrint on and no pino.transport set, a pattern set here also formats the time on lines written through store.pino, so they show the same clock reading as the text console line; a transport you configure is left alone. standard is the one pattern where the two lines differ: the pino line keeps pino-pretty’s own standard form, which ends with the zone offset (2026-01-02 10:04:05.678 +0700), and the console line has no offset. A translateTime set inside pino.prettyPrint is passed to pino-pretty as written and takes precedence.
Formatting Options
consoleFormat
What the console prints per record. 'text' is the human line with its context tree. 'json' is one line of JSON holding the record transports receive, with timestamp, level, message, request, status, durationMs, context and error. The prod and json presets set 'json'. The file sink has its own switch, fileFormat. Any other value throws logixlysia: invalid formatting config at startup.
- Type:
'text' | 'json' - Default:
'text'
consoleFormat: 'json'
The JSON line ignores customLogFormat, useColors, showContextTree, contextDepth and timestamp. See Presets for the key order and an example line.
customLogFormat
Custom log message format using placeholders.
- Type:
string - Default:
undefined
Any value other than a string throws logixlysia: invalid formatting config at startup.
customLogFormat: '{now} {level} {duration} {method} {pathname} {status}'
When customLogFormat is omitted, Logixlysia uses a built-in default that includes {now}, {service}, {icon}, {method}, {pathname}, {status}, {duration}, {message}, and {speed}.
Available placeholders:
{now}- Current timestamp{level}- Log level{duration}- Request duration (formatted, e.g.12ms,1.5s){method}- HTTP method{pathname}- Request path{path}- Alias of{pathname}{query}- Raw query string (e.g.?id=123), printed whateverlogQueryParamssays. WithlogQueryParams: true,{pathname}already includes it, so use one or the other{status}- Response status code{statusText}- HTTP status text from Node’shttp.STATUS_CODES(e.g.Not Foundfor 404){message}- Custom message{icon}- with colors on a TTY, the Logixlysia fox (🦊) in a level-colored background chip; otherwise the level word (DEBUG,INFO,WARN,ERROR){speed}- When duration is at or aboveverySlowThreshold, appends⚡ slow(yellow when colors are on){service}- Service label from theserviceconfig option, shown as[name](dim when colors are on); empty if unset{context}- Request context as JSON whenshowContextTreeis off; empty while the context tree shows it{ip}- Client IP (fromx-forwarded-fororx-real-ip; seeipoption){epoch}- Unix time in milliseconds{requestId}- Request ID whenrequestIdis on; empty otherwise
service
Service name. The {service} placeholder prints it as a [my-app] prefix.
- Type:
string - Default:
undefined(no prefix)
The JSON console line and the record a transport receives carry it as the service key, and it wins over a service key in the logged data. An adapter’s own service option (service for Datadog, serviceName for OTLP, HyperDX and Loki) still names the service in that backend. The Datadog and Loki adapters use the plugin’s service when their own option and environment variables are unset.
service: 'my-api'
slowThreshold
Duration threshold (ms) for green duration text when colors are enabled. Between this value and verySlowThreshold, duration is yellow. Must be a finite number at or above 0, and slowThreshold must not exceed verySlowThreshold; otherwise startup throws logixlysia: invalid formatting config.
- Type:
number - Default:
500
slowThreshold: 500
verySlowThreshold
Duration threshold (ms) at or above which duration is red (bold when colors are on) and the {speed} token adds ⚡ slow. Must be a finite number at or above 0, and slowThreshold must not exceed verySlowThreshold; otherwise startup throws logixlysia: invalid formatting config.
- Type:
number - Default:
1000
verySlowThreshold: 1000
showContextTree
When true, structured context passed to logger helpers is printed as tree lines under the main log line instead of being crammed into {message} on the same line.
- Type:
boolean - Default:
true
showContextTree: true
contextDepth
How many levels of nested objects to expand in the context tree. At the default, { user: { id: 'usr_123', org: { id: 'org_9' } } } prints user.id usr_123 and user.org {"id":"org_9"}. Set 1 to print user as one JSON value.
- Type:
number - Default:
2
contextDepth: 3
On a TTY, a string value longer than 200 characters is cut to 200 and ends in … (<length> chars). Piped stdout, files and transports always get the whole string.
Output Options
transports
Array of custom transport implementations.
- Type:
Transport[] - Default:
[]
transports: [
{
log: async (level, message, meta) => {
// Custom transport logic
}
}
]
A value that is not an array, or an entry whose log is not a function, makes the plugin throw logixlysia: invalid output config when you construct it. The message names the offending entry by index, such as transports[1].log must be a function, got undefined.
useTransportsOnly
Use only transports, disable console and file logging.
- Type:
boolean - Default:
false
useTransportsOnly: true
useTransportsOnly: true requires at least one entry in transports. If transports is empty or missing, the plugin throws logixlysia: invalid output config when you construct it. This includes a conditional list that can end up empty, such as token ? [createAxiomTransport({ apiKey: token })] : []. Set useTransportsOnly only when a transport is present:
const token = process.env.AXIOM_API_KEY
const app = new Elysia().use(
logixlysia({
config: {
transports: token ? [createAxiomTransport({ apiKey: token })] : [],
useTransportsOnly: Boolean(token)
}
})
)
To turn every sink off, set disableInternalLogger: true and disableFileLogging: true instead.
disableInternalLogger
Disable console logging.
- Type:
boolean - Default:
false
disableInternalLogger: true
disableFileLogging
Disable file logging.
- Type:
boolean - Default:
false
disableFileLogging: true
onError
Called when a sink (transport, file, or rotation) or an enricher fails, and when a shutdown flush runs out of time (sink: 'shutdown'). sink: 'format' means building or printing a log record failed. sink: 'sampling' means a sampling.tail.keep predicate threw. The request itself is unaffected. Errors thrown by the hook itself are swallowed. When absent, failures go to stderr (rate-limited for transports, file writes, rotation, enrichers, and formatting).
- Type:
(context: { sink: 'transport' | 'file' | 'rotation' | 'shutdown' | 'enricher' | 'format' | 'sampling'; error: unknown }) => void - Default:
undefined
onError: ({ sink, error }) => {
metrics.increment(`logixlysia.sink_error.${sink}`)
}
flushTimeoutMs
How long the plugin waits for transports and the file sink to flush when the app stops. 0 starts the flush but does not wait. An app-stop flush that exceeds the budget is reported through onError with sink: 'shutdown'. Transports receive the deadline as { signal }, so once it passes, the retries the built-in adapters started no longer hold the process open.
- Type:
number - Default:
5000
The value must be a finite number between 0 and 2147483647 (the largest delay setTimeout supports). Infinity, NaN, negative values, and values above 2147483647 make the plugin throw logixlysia: invalid output config when you construct it.
flushTimeoutMs: 2000
waitUntil
After each request or runJob job finishes, the plugin flushes every transport and the file sink, bounded by flushTimeoutMs, and passes the promise to waitUntil. Pass the platform’s function to keep a serverless invocation alive while the flush completes. With flushTimeoutMs: 0, the promise settles at once, so the platform does not wait for delivery. Leave it unset on a long-running server, where batches are sent on their interval and at shutdown.
- Type:
(promise: Promise<void>) => void - Default: unset
A value that is not a function throws at startup.
import { waitUntil } from '@vercel/functions'
import logixlysia from 'logixlysia'
import { createAxiomTransport } from 'logixlysia/axiom'
logixlysia({ config: { transports: [createAxiomTransport()], waitUntil } })
enrichers
Context contributors run on every request. Whatever they return is merged into the request context, so the fields reach the console tree, file logs, and every transport at once. See Enrichers. A value that is not an array, or an entry that is neither a function nor an object whose request and response, if provided, are functions, throws at startup.
- Type:
EnricherLike[] - Default:
undefined
import { geoEnricher, traceparentEnricher } from 'logixlysia/enrichers'
enrichers: [
traceparentEnricher(),
geoEnricher(),
request => ({ tenant: request.headers.get('x-tenant') })
]
requestId
Reads the request id from the configured header or generates one, and echoes it on the response; see request IDs.
- Type:
boolean | RequestIdConfig - Default:
undefined
requestId: true
requestId.header must be a valid HTTP header name: letters, digits, and !#$%&'*+.^_`|~-, with no spaces. A value such as 'X Request Id' makes the plugin throw logixlysia: invalid requestId config when you construct it. An empty or blank header falls back to X-Request-Id.
A requestId.generator that is not a function throws at startup. If a custom requestId.generator throws or returns an id that does not match ^[A-Za-z0-9._-]{1,128}$, the plugin uses a random UUID for that request instead. It reports the failure through onError with sink: 'enricher'. Without onError, it writes the failure to stderr at most once every 5 seconds.
useAsyncLocalStorage
Makes useLogger() return the current request’s logger from anywhere in the call stack; without it useLogger() is a no-op and warns once on stderr outside production. See request context.
- Type:
boolean - Default:
false
useAsyncLocalStorage: true
disableWebSocketLogging
Turns off the open, message and close lines that wrapWs writes; see WebSocket logging.
- Type:
boolean - Default:
false
disableWebSocketLogging: true
Filtering Options
logFilter
Restricts which log levels get processed and which routes are logged, and can hide the access line of chosen paths. See Filtering.
- Type:
{ level?: LogLevel[]; include?: string[]; exclude?: string[]; accessLine?: { include?: string[]; exclude?: string[] } } - Default: all levels, all paths
level must be an array containing only 'DEBUG', 'INFO', 'WARNING', or 'ERROR'. Any other value, such as 'WARN', makes the plugin throw logixlysia: invalid logFilter config when you construct it. So does an include, exclude, accessLine.include or accessLine.exclude that is not an array of non-empty glob strings. An include, exclude, accessLine.include or accessLine.exclude that holds a glob the matcher rejects throws too, naming the key and the glob.
include and exclude are globs on the request pathname, with the query string left out. A request matching exclude, or missing a non-empty include, writes no record at all. exclude beats include. ** crosses /; * and ? do not.
logFilter: {
level: ['ERROR', 'WARNING'],
include: ['/api/**'],
exclude: ['/api/internal/**']
}
Sampling Options
sampling
Head + tail sampling. Head sampling keeps a percentage of records per level; tail sampling replays what head dropped once the finished request matches a rule. See Sampling for the full guide.
- Type:
{ head?: Partial<Record<LogLevel, number>>; tail?: { status?: number; durationMs?: number; paths?: string[]; keep?: (outcome: RequestOutcome) => boolean }; maxBufferedPerRequest?: number } - Default:
undefined(no sampling)
sampling: {
head: { DEBUG: 1, INFO: 10 }, // levels left out keep 100%
tail: {
status: 400, // rescue any response at or above 400
durationMs: 1000, // rescue anything that took a second or longer
paths: ['/checkout/**'] // rescue these routes whatever happened
},
maxBufferedPerRequest: 100
}
Sampling is off unless at least one head rate is below 100 — tail alone rescues nothing, because only head-dropped records are buffered. Invalid values throw at plugin construction.
File Logging Options
logFilePath
Path to the log file.
- Type:
string - Default:
undefined
logFilePath: './logs/app.log'
fileFormat
What the log file gets per record. 'text' is the plain line: time, level, method, path, status, duration, message and context. 'json' is the JSON console line, one object per line, with the same keys, the same order and the same redaction. Rotation and retention work the same for both. No preset sets it. Any other value throws logixlysia: invalid formatting config at startup.
- Type:
'text' | 'json' - Default:
'text'
fileFormat: 'json'
logDirMode
Mode for the directories the file sink creates.
- Type:
number - Default:
0o700
logDirMode: 0o750
logFileMode
Mode for the log files the sink creates. Compressed rotation archives use it too.
- Type:
number - Default:
0o600
logFileMode: 0o640
logRotation
Log rotation configuration.
- Type:
LogRotationConfig - Default:
undefined
logRotation: {
maxSize: '10m',
maxFiles: '7d',
compress: true
}
logRotation.maxSize
Maximum file size before rotation.
- Type:
string | number - Format:
'1k','1m','1g'or bytes
logRotation: {
maxSize: '10m'
}
logRotation.interval
Rotate when the live log file’s age reaches the given interval. Evaluated on write — an idle process does not rotate until it logs again. See Log Rotation for details.
- Type:
string - Format:
'1h','1d','1w'
logRotation.maxFiles
Maximum number of files or retention period. A number must be a positive integer; 0 or a negative value is rejected at startup.
- Type:
number | string - Format: Positive integer or
'7d','30d'
logRotation: {
maxFiles: '7d' // or 10
}
logRotation.compress
Enable compression for rotated logs.
- Type:
boolean - Default:
false
logRotation: {
compress: true
}
logRotation.compression
Compression algorithm.
- Type:
'gzip' - Default:
'gzip'
logRotation: {
compression: 'gzip'
}
Pino Options
pino
Pino logger configuration. Accepts all Pino options.
- Type:
PinoLoggerOptions & { prettyPrint?: boolean | object } - Default:
undefined
pino: {
level: 'info',
prettyPrint: true,
redact: ['password', 'token'],
base: {
service: 'my-api',
version: '1.0.0'
}
}
Common Pino Options
Every pino.* option configures the pino instance exposed as store.pino; none of them changes what the plugin logs for a request.
pino.level
Minimum level for store.pino only. The plugin’s own lines are filtered by logFilter.
- Type:
'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' - Default:
'info'
pino: {
level: 'debug'
}
pino.prettyPrint
Enable pretty printing for development.
- Type:
boolean | object - Default:
false
pino: {
prettyPrint: true
}
Or with options:
pino: {
prettyPrint: {
colorize: true,
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname'
}
}
Common prettyPrint Options
| Option | Type | Description |
|---|---|---|
colorize |
boolean |
Enable colors in output |
translateTime |
string | boolean |
Format timestamps |
ignore |
string |
Comma-separated keys to exclude |
singleLine |
boolean |
Print each log on one line |
messageFormat |
string |
Custom message format |
levelFirst |
boolean |
Show level before timestamp |
messageKey |
string |
Key containing log message |
errorKey |
string |
Key containing error info |
See pino-pretty documentation for complete reference.
pino.redact
Redact paths for store.pino only. The plugin’s own console, file and transport output is masked by autoRedact and redactKeys; setting pino.redact also replaces the automatic paths and key masking autoRedact would give store.pino.
- Type:
string[] | object - Default:
undefined
pino: {
redact: ['password', 'token', 'apiKey']
}
Or with paths:
pino: {
redact: {
paths: ['user.password', 'req.headers.authorization'],
remove: true
}
}
pino.base
Base fields added to every store.pino record. They do not appear on the plugin’s own lines.
- Type:
object - Default:
undefined
pino: {
base: {
service: 'my-api',
version: '1.0.0',
environment: process.env.NODE_ENV
}
}
Complete Example
logixlysia({
config: {
// Startup
showStartupMessage: true,
startupMessageFormat: 'banner',
// Display
useColors: true,
ip: true,
autoRedact: false,
logQueryParams: false,
// Formatting
timestamp: {
translateTime: 'yyyy-mm-dd HH:MM:ss'
},
customLogFormat:
'{now} {level} {duration} {ip} {method} {pathname} {status}',
// File Logging
logFilePath: './logs/app.log',
logRotation: {
maxSize: '100m',
maxFiles: '30d',
compress: true
},
// Output Control
disableInternalLogger: false,
disableFileLogging: false,
useTransportsOnly: false,
transports: [],
// Pino
pino: {
level: 'info',
prettyPrint: false,
redact: ['password', 'token'],
base: {
service: 'my-api',
version: '1.0.0'
}
}
}
})