app.silent
Suppresses Koa's built-in error logging to `stderr` when set to `true`.
Syntax
app.silent = true | false Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value | boolean | Yes | When `true`, Koa will not log errors to `stderr`. Useful when you supply your own `app.on('error', ...)` handler. Defaults to `false`. |
Returns
void — Setter; returns nothing.
Examples
import Koa from 'koa';
const app = new Koa();
app.silent = true;
app.on('error', (err, ctx) => {
// Custom structured logging
console.error(JSON.stringify({ msg: err.message, path: ctx.path }));
});
app.use(async (ctx) => {
ctx.throw(400, 'Bad input');
});
app.listen(3000);
Output
{"msg":"Bad input","path":"/"}
Notes
By default Koa logs 5xx errors via `console.error`; 4xx errors are never
logged (they are expected client errors). Set `app.silent = true` when you
attach a structured logger via `app.on('error', ...)` to avoid duplicate
output.