Skip to content

Commit

Permalink
chore(logs in context) - update Java config snippets
Browse files Browse the repository at this point in the history
Updated Java config snippets to be more complete/transparent.
  • Loading branch information
mnevilleoneill committed May 9, 2022
1 parent 03d6463 commit 7753d5f
Showing 1 changed file with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If you are using a different logging framework, our [manual logs in context](#en

Using this option, your logs will include `span.id`, `trace.id`, `hostname`, `entity.guid`, and `entity.name`. These attributes automatically link your logs to spans, traces, and other telemetry, making it easier to troubleshoot.

This feature may be enabled by default in a future agent version.
This functionality is enabled by default.

All you need to do is install an agent version with log forwarding capabilities ([Java agent 7.6.0 or higher](/docs/release-notes/agent-release-notes/java-release-notes/)), and update your configuration to enable forwarding.

Expand All @@ -99,20 +99,27 @@ If you are using a different logging framework, our [manual logs in context](#en
enabled: true
forwarding:
enabled: true
max_samples_stored: 10000
local_decorating:
enabled: false
```

Environment variable:

```
NEW_RELIC_APPLICATION_LOGGING_ENABLED=true
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED=true
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED=10000
NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=false
```

System property:

```
-Dnewrelic.config.application_logging.enabled=true
-Dnewrelic.config.application_logging.forwarding.enabled=true
-Dnewrelic.config.application_logging.forwarding.max_samples_stored=10000
-Dnewrelic.config.application_logging.local_decorating.enabled=false
```

**Optional adjustments:**
Expand All @@ -125,20 +132,30 @@ If you are using a different logging framework, our [manual logs in context](#en

```
application_logging:
enabled: true
forwarding:
max_samples_stored: 10000
enabled: true
**max_samples_stored: 10000**
local_decorating:
enabled: false
```

Environment variable:

```
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED=10000
NEW_RELIC_APPLICATION_LOGGING_ENABLED=true
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED=true
**NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED=10000**
NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=false
```

System property:

```
-Dnewrelic.config.application_logging.forwarding.max_samples_stored=10000
-Dnewrelic.config.application_logging.enabled=true
-Dnewrelic.config.application_logging.forwarding.enabled=true
**-Dnewrelic.config.application_logging.forwarding.max_samples_stored=10000**
-Dnewrelic.config.application_logging.local_decorating.enabled=false
```

<Callout variant="important">
Expand All @@ -158,51 +175,33 @@ If you are using a different logging framework, our [manual logs in context](#en

This option should not be used with in-agent forwarding. Using an [external log forwarder](/docs/logs/forward-logs/enable-log-management-new-relic#log-forwarding) to send logs to New Relic while in-agent forwarding is enabled will cause your logs to be sent up twice to New Relic. Depending on your account, this may result in double billing.

1. If you want to use this option, make sure you have the in-agent forwarding configuration option disabled.
Update your agent's configuration to disable log forwarding and enable local decoration, then restart the agent to start decorating your logs.

Configuration file (`newrelic.yml`), indented 2 spaces under the common stanza:

```
application_logging:
enabled: true
forwarding:
enabled: false
application_logging:
enabled: true
local_decorating:
enabled: true
forwarding:
enabled: false
```

Environment variable:

```
NEW_RELIC_APPLICATION_LOGGING_ENABLED=true
NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=true
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED=false
```

System property:

```
-Dnewrelic.config.application_logging.enabled=true
-Dnewrelic.config.application_logging.forwarding.enabled=false
```

2. Enable log decorating in your configuration, then restart the agent to start decorating your logs.

Configuration file (`newrelic.yml`):

```
application_logging:
local_decorating:
enabled: true
```

Environment variable:

```
NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=true
```

System property:

```
-Dnewrelic.config.application_logging.local_decorating.enabled=true
-Dnewrelic.config.application_logging.forwarding.enabled=false
```

Our decorator adds five attributes to every log message in your application log file: `entity.guid`, `hostname`, `trace.id`, `span.id` and `entity.name`. Example:
Expand Down

0 comments on commit 7753d5f

Please sign in to comment.