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
Copy file name to clipboardExpand all lines: docs/core/logger.md
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,9 @@ These settings will be used across all logs emitted:
52
52
|**Logging level**| Sets how verbose Logger should be, from the most verbose to the least verbose (no logs) |`POWERTOOLS_LOG_LEVEL`|`INFO`|`DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `SILENT`|`ERROR`|`logLevel`|
53
53
|**Sample rate**| Probability that a Lambda invocation will print all the log items regardless of the log level setting |`POWERTOOLS_LOGGER_SAMPLE_RATE`|`0`|`0.0` to `1.0`|`0.1`|`sampleRateValue`|
54
54
55
+
???+ info
56
+
When `POWERTOOLS_DEV` environment variable is present and set to `"true"` or `"1"`, Logger will pretty-print log messages for easier readability. We recommend to use this setting only when debugging on local environments.
57
+
55
58
See all environment variables in the [Environment variables](../index.md/#environment-variables) section.
56
59
Check API docs to learn more about [Logger constructor options](https://docs.powertools.aws.dev/lambda/typescript/latest/api/types/_aws_lambda_powertools_logger.types.ConstructorOptions.html){target="_blank"}.
57
60
@@ -91,8 +94,8 @@ Your Logger will include the following keys to your structured logging (default
91
94
|**xray_trace_id**: `string`|`1-5759e988-bd862e3fe1be46a994272793`| X-Ray Trace ID. This value is always presented in Lambda environment, whether [tracing is enabled](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html){target="_blank"} or not. Logger will always log this value. |
92
95
|**error**: `Object`|`{ name: "Error", location: "/my-project/handler.ts:18", message: "Unexpected error #1", stack: "[stacktrace]"}`| Optional - An object containing information about the Error passed to the logger |
93
96
94
-
???+ info
95
-
When `POWERTOOLS_DEV` environment variable is present and set to `"true"`or `"1"`, Logger will pretty-print log messages for easier readability. We recommend to use this setting only when debugging on local environments.
97
+
???+ note
98
+
If you emit a log message with a key that matches one of `level`, `message`, `sampling_rate`, `service`, or `timestamp`, the Logger will log a warning message and ignore the key.
96
99
97
100
### Capturing Lambda context info
98
101
@@ -211,6 +214,8 @@ You can append additional keys using either mechanism:
211
214
* Append **temporary keys** to all future log messages via the `appendKeys()` method until `resetKeys()` is called
212
215
* Set **Persistent keys** for the logger instance via the `persistentKeys` constructor option or the `appendPersistentKeys()` method
213
216
217
+
To prevent you from accidentally overwriting some of the [standard keys](#standard-structured-keys), we will log a warning message and ignore the key if you try to overwrite them.
218
+
214
219
#### Extra keys
215
220
216
221
You can append additional data to a single log item by passing objects as additional parameters.
* Add the given persistent attributes (key-value pairs) to all log items generated by this Logger instance.
209
-
*
210
-
* @deprecated This method is deprecated and will be removed in the future major versions, please use {@link appendPersistentKeys()} instead.
211
-
*
212
-
* @param attributes - The attributes to add to all log items.
212
+
* @deprecated This method is deprecated and will be removed in the future major versions, please use {@link appendPersistentKeys() `appendPersistentKeys()`} instead.
* Set the given attributes (key-value pairs) to all log items generated by this Logger instance.
557
-
* Note: this replaces the pre-existing value.
558
-
*
559
-
* @deprecated This method is deprecated and will be removed in the future major versions, please use {@link appendPersistentKeys()} instead.
560
-
*
561
-
* @param attributes - The attributes to set.
554
+
* @deprecated This method is deprecated and will be removed in the future major versions, please use {@link appendPersistentKeys() `appendPersistentKeys()`} instead.
0 commit comments