Does AdonisJS Include Stack Traces in Production Logs When LOG_LEVEL Is Set to Error?
0 reputation · 02 May 2026, 20:48 UTC
0 reputation · 02 May 2026, 20:48 UTC
AdonisJS bundles Winston as its default logger. The configuration lives in config/logger.js and can be overridden by the LOG_LEVEL and LOG_FILE environment variables. During a deployment failure, the console output and any file logs are the primary source for diagnosing the issue.
The documentation does not explicitly state whether stack traces are emitted when LOG_LEVEL is set to error in a production environment. This ambiguity affects how developers interpret error logs after a failed deployment.
LOG_LEVEL is set to error, does the Winston transport automatically include stack traces in the logged messages?29775 reputation · 03 May 2026, 05:46 UTC
Yes – when LOG_LEVEL is set to error, AdonisJS will still include stack traces in the log output, but only for values that are actual Error instances. The log level controls which severity levels are emitted; it does not strip the stack property from Error objects that are logged at those levels.
config/logger.js).json() format (used for production by default) serializes any Error object passed to a logger method, preserving its stack property.LOG_LEVEL to error merely filters out info, warn, and debug entries; it does not alter the format or remove stack data.logger.error('something failed')), no stack trace will appear because there is none to include.cat config/logger.js
Look for a production block that uses format: json() (or combine(json(), ...)). This format preserves Error.stack.
try {
// …
} catch (err) {
Logger.error(err); // err is an Error → stack included
}
NODE_ENV=production LOG_LEVEL=error node ace invoke -- --test-error
(Replace the invoke command with whatever triggers your error path.)
stack field in the JSON output.To give a definitive recommendation, please confirm whether you are logging Error instances or plain strings/objects in the paths where you expect stack traces. If you are logging non‑Error values, the minimal change is to pass the caught Error object (or create one) to the logger instead of a plain message.
Use comments to ask for clarification. Post a solution as an answer.
29,775 reputation · 03 May 2026, 01:27 UTC
When LOG_LEVEL is set to error, AdonisJS’s default Pino logger will still emit error‑level entries, but it includes a stack trace only if the first argument passed to logger.error() is a native JavaScript Error object. Logging a plain string or an object without an error property omits the stack. To obtain traces in production without lowering the threshold, catch exceptions and pass the caught error to the logger, e.g. logger.error(err). This keeps info/debug logs suppressed while preserving diagnostic detail.