Skip to content

fix: powertools specific log level env var to not conflict with the system LOG_LEVEL #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/core/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Powertools extends the functionality of Log4J. Below is an example log4j2.xml fi
</Configuration>
```

You can also override log level by setting `LOG_LEVEL` env var - Here is an example using AWS Serverless Application Model (SAM)
You can also override log level by setting `POWERTOOLS_LOG_LEVEL` env var - Here is an example using AWS Serverless Application Model (SAM)

```yaml:title=template.yaml
Resources:
Expand All @@ -48,7 +48,7 @@ Resources:
Runtime: java8
Environment:
Variables:
LOG_LEVEL: DEBUG # highlight-line
POWERTOOLS_LOG_LEVEL: DEBUG # highlight-line
```

You can also explicitly set a service name via `POWERTOOLS_SERVICE_NAME` env var. This sets **service** key that will be present across all log statements.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Environment variable | Description | Utility
**POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All
**POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics)
**POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging)
**LOG_LEVEL** | Sets logging level | [Logging](./core/logging)
**POWERTOOLS_LOG_LEVEL** | Sets logging level | [Logging](./core/logging)
**POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Enables/Disables tracing mode to capture method response | [Tracing](./core/tracing)
**POWERTOOLS_TRACER_CAPTURE_ERROR** | Enables/Disables tracing mode to capture method error | [Tracing](./core/tracing)

Expand Down
2 changes: 1 addition & 1 deletion example/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Resources:
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
POWERTOOLS_SERVICE_NAME: "Payment Service"
LOG_LEVEL: INFO
POWERTOOLS_LOG_LEVEL: INFO
Tracing: Active
Events:
HelloWorld:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class LambdaLoggingAspect {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final Random SAMPLER = new Random();

private static final String LOG_LEVEL = System.getenv("LOG_LEVEL");
private static final String LOG_LEVEL = System.getenv("POWERTOOLS_LOG_LEVEL");
private static final String SAMPLING_RATE = System.getenv("POWERTOOLS_LOGGER_SAMPLE_RATE");

private static Level LEVEL_AT_INITIALISATION;
Expand Down