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
|**Service name**| Sets the name of service of which the Lambda function is part of, that will be present across all log statements |`POWERTOOLS_SERVICE_NAME`|`service_undefined`| Any string |`serverlessAirline`|`serviceName`|
52
-
|**Logging level**| Sets how verbose Logger should be|`LOG_LEVEL`|`info`|`DEBUG`, `INFO`, `WARN`, `ERROR`|`ERROR`|`logLevel`|
53
-
|**Log incoming event**| Whether to log or not the incoming event when using the decorator or middleware.|`POWERTOOLS_LOGGER_LOG_EVENT`|`false`|`true`, `false`|`false`|`logEvent`|
54
-
|**Debug log sampling**| 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.5`|`sampleRateValue`|
49
+
| Setting | Description | Environment variable | Default Value | Allowed Values | Example Value | Constructor parameter |
|**Service name**| Sets the name of service of which the Lambda function is part of, that will be present across all log statements |`POWERTOOLS_SERVICE_NAME`|`service_undefined`| Any string |`serverlessAirline`|`serviceName`|
52
+
|**Logging level**| Sets how verbose Logger should be, from the most verbose to the least verbose (no logs)|`LOG_LEVEL`|`info`|`DEBUG`, `INFO`, `WARN`, `ERROR`, `SILENT`|`ERROR`|`logLevel`|
53
+
|**Log incoming event**| Whether to log or not the incoming event when using the decorator or middleware |`POWERTOOLS_LOGGER_LOG_EVENT`|`false`|`true`, `false`|`false`|`logEvent`|
54
+
|**Debug log sampling**| 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.5`|`sampleRateValue`|
55
55
56
56
#### Example using AWS Serverless Application Model (SAM)
57
57
@@ -81,7 +81,7 @@ Your Logger will include the following keys to your structured logging (default
|**level**: `string`|`INFO`| Logging level set for the Lambda function"s invocation |
84
+
|**level**: `string`|`INFO`| Logging level set for the Lambda function's invocation |
85
85
|**message**: `string`|`Query performed to DynamoDB`| A descriptive, human-readable representation of this log item |
86
86
|**sampling_rate**: `float`|`0.1`| When enabled, it prints all the logs of a percentage of invocations, e.g. 10% |
87
87
|**service**: `string`|`serverlessAirline`| A unique name identifier of the service this Lambda function belongs to, by default `service_undefined`|
@@ -555,6 +555,17 @@ For example, by setting the "sample rate" to `0.5`, roughly 50% of your lambda i
555
555
}
556
556
```
557
557
558
+
### Silencing logs
559
+
560
+
The `SILENT` log level provides a simple and efficient way to suppress all log messages without the need to modify your code. When you set this log level, all log messages, regardless of their severity, will be silenced.
561
+
562
+
This feature is useful when you want to have your code instrumented to produce logs, but due to some requirement or business decision, you prefer to not emit them.
563
+
564
+
By setting the log level to `SILENT`, which can be done either through the `logLevel` constructor option or by using the `LOG_LEVEL` environment variable, you can easily suppress all logs as needed.
565
+
566
+
!!! note
567
+
Use the `SILENT` log level with care, as it can make it more challenging to monitor and debug your application. Therefore, we advise using this log level judiciously.
568
+
558
569
### Custom Log formatter (Bring Your Own Formatter)
559
570
560
571
You can customize the structure (keys and values) of your log items by passing a custom log formatter, an object that implements the `LogFormatter` abstract class.
0 commit comments