Skip to content

Commit a629b3e

Browse files
authored
chore: update readme with auto-population and redirect to stdout info (#655)
1 parent a233647 commit a629b3e

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

.readme-partials.yaml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ custom_content: |
1919
<!-- Optional: defaults to "ERROR" -->
2020
<flushLevel>WARNING</flushLevel>
2121
22-
<!-- Optional: auto detects on App Engine Flex, Standard, GCE and GKE, defaults to "global". See supported resource types -->
22+
<!-- Optional: defaults to ASYNC -->
23+
<writeSynchronicity>SYNC</writeSynchronicity>
24+
25+
<!-- Optional: defaults to true -->
26+
<autoPopulateMetadata>false</autoPopulateMetadata>
27+
28+
<!-- Optional: defaults to false -->
29+
<redirectToStdout>true</redirectToStdout>
30+
31+
<!-- Optional: auto detects on App Engine Flex, Standard, GCE and GKE, defaults to "global". -->
2332
<resourceType></resourceType>
2433
2534
<!-- Optional: defaults to the default credentials of the environment -->
@@ -39,7 +48,7 @@ custom_content: |
3948
</configuration>
4049
```
4150
42-
In your code :
51+
In your code:
4352
4453
```java
4554
import org.slf4j.Logger;
@@ -57,4 +66,31 @@ custom_content: |
5766
testLogger.log("test");
5867
}
5968
}
60-
```
69+
```
70+
71+
### Populate log entries with metadata
72+
73+
The library provides multiple ways to enrich log entries with additional information.
74+
You can select one or more ways to customize log entries that will be written into Cloud Logging.
75+
76+
* Manually update a log entry using [`LoggingEnhancer`]
77+
(https://github.com/googleapis/java-logging/blob/main/google-cloud-logging/src/main/java/com/google/cloud/logging/.
78+
* Use [`ILoggingEvent`](https://logback.qos.ch/apidocs/ch/qos/logback/classic/spi/ILoggingEvent.html) to update a log entry with [`LoggingEventEnhancer`]
79+
(https://github.com/googleapis/java-logging-logback/blob/main/src/main/java/com/google/cloud/logging/logback/LoggingEventEnhancer.java).
80+
* Enable [auto-population](https://github.com/googleapis/java-logging#auto-population-of-log-entrys-metadata) of the `LogEntry` metadata using the `autoPopulateMetadata` configuration flag.
81+
82+
#### Optimize log ingestion
83+
84+
By default, the appender will ingest log entries asynchronously by calling Logging API.
85+
Multiple calls may be aggregated before being sent to improve use of API quota and bandwidth.
86+
You can set the `writeSynchronicity` configuration flag to `SYNC` if they want to ingest log entries synchronously.
87+
Note that configuring synchronous ingestion will probably result in performance penalties to your applications.
88+
If you plan to deploy your application in one of Google Cloud managed environments (e.g. Cloud Run, Cloud Function or App Engine),
89+
you can leverage the support provided by the implicit logging agent and the [structured logging](https://cloud.google.com/logging/docs/structured-logging) feature.
90+
To use it, set the `redirectToStdout` configuration flag to `true`.
91+
This flag instructs the appender to print the log entries to `stdout` instead of ingesting them using Logging API.
92+
The log entries are printed using the [structured logging Json format](https://cloud.google.com/logging/docs/structured-logging#special-payload-fields).
93+
In result, the logging agent will be responsible for ingesting the logs to Logging API.
94+
Note that using the structured logging Json format you cannot control the log name where the logs will be ingested.
95+
The logs will be ingested into the project that hosts the environment where your application is running.
96+
The configuration `logDestinationProjectId` will be ignored.

0 commit comments

Comments
 (0)