Skip to content

Commit

Permalink
Improve docs (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
skjolber authored Jan 20, 2025
1 parent 72f60ad commit 004b8aa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
42 changes: 32 additions & 10 deletions guides/gRPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,47 @@ Add the `GrpcLoggingScopeContextInterceptor` interceptor to your gRPC services.
## Running applications locally
For 'classic' one-line log output when running a server locally, additionally add the logging test artifacts to the main scope during local execution only.

* Maven: Use profiles
* Gradle:
* Use configurations, and/or
* add dependencies directly to task
* Maven: Use profiles
* Gradle:
* Use configurations, and/or
* add dependencies directly to task

<details>
<summary>Gradle bootRun example</summary>

```groovy
bootRun {
dependencies {
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-web-test")
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-web-test")
}
dependencies {
// Setup HumanReadableJsonApplicationListener without reflection
compileOnly("no.entur.logging.cloud:test-logback") { transitive = false }
}
```
tasks.register("logPlainly") {
dependencies {
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-grpc-ecosystem-test")
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-grpc-ecosystem-test")
}
}
tasks.withType(JavaExec).configureEach {
dependsOn("logPlainly")
}
```
</details>

Add an event listener to set your preferred log output:

```
@Component
@ConditionalOnClass(name = {"no.entur.logging.cloud.logback.logstash.test.CompositeConsoleOutputControl"})
public class HumanReadableJsonApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
CompositeConsoleOutputControl.useHumanReadableJsonEncoder();
}
}
```

## Opting out
Some included features can be removed by excluding the corresponding artifacts:

Expand Down
22 changes: 15 additions & 7 deletions guides/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,30 @@ For 'classic' one-line log output when running a server locally, additionally ad
<summary>Gradle bootRun example</summary>

```groovy
bootRun {
dependencies {
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-web-test")
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-web-test")
}
dependencies {
// Setup HumanReadableJsonApplicationListener without reflection
compileOnly("no.entur.logging.cloud:test-logback") { transitive = false }
}
tasks.register("logPlainly") {
dependencies {
implementation("no.entur.logging.cloud:request-response-spring-boot-starter-gcp-web-test")
implementation("no.entur.logging.cloud:spring-boot-starter-gcp-web-test")
}
}
tasks.withType(JavaExec).configureEach {
dependsOn("logPlainly")
}
```

</details>

## Toggle output mode using profiles
Add an event listener to set your preferred log output:

```
@Component
@Profile("local")
@ConditionalOnClass(name = {"no.entur.logging.cloud.logback.logstash.test.CompositeConsoleOutputControl"})
public class HumanReadableJsonApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
@Override
Expand Down

0 comments on commit 004b8aa

Please sign in to comment.