You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -347,14 +376,14 @@ The error will be logged with default key name `error`, but you can also pass yo
347
376
throw new Error('Unexpected error #1');
348
377
} catch (error) {
349
378
// Log information about the error using the default "error" key
350
-
logger.error('This is the first error', error);
379
+
logger.error('This is the first error', error as Error);
351
380
}
352
381
353
382
try {
354
383
throw new Error('Unexpected error #2');
355
384
} catch (error) {
356
385
// Log information about the error using a custom "myCustomErrorKey" key
357
-
logger.error('This is the second error', { myCustomErrorKey: error } );
386
+
logger.error('This is the second error', { myCustomErrorKey: error as Error } );
358
387
}
359
388
360
389
};
@@ -391,6 +420,9 @@ The error will be logged with default key name `error`, but you can also pass yo
391
420
}
392
421
```
393
422
423
+
!!! tip "Logging errors and log level"
424
+
You can also log errors using the `warn`, `info`, and `debug` methods. Be aware of the log level though, you might miss those errors when analyzing the log later depending on the log level configuration.
425
+
394
426
## Advanced
395
427
396
428
### Using multiple Logger instances across your code
0 commit comments