Skip to content

Commit

Permalink
Remove logbook exclude properties defaults (#71)
Browse files Browse the repository at this point in the history
* Fix logbook exclude properties defaults

* Fix expressions

* Remove use of default exclude properties
  • Loading branch information
skjolber authored Jan 20, 2025
1 parent 004b8aa commit 824f224
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
entur.logging.request-response.max-size=16384
entur.logging.request-response.max-body-size=14336

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions examples/gcp-web-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {

implementation("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")

testImplementation project(":gcp:spring-boot-starter-gcp-web-test");
testImplementation project(":gcp:request-response-spring-boot-starter-gcp-web-test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ logging.level.org.entur=debug
logging.level.root=debug


management.endpoint.health.probes.enabled: true

logbook.filter.enabled: true

logbook.predicate.exclude[0].path=/actuator/health/liveness
logbook.predicate.exclude[1].path=/actuator/health/readiness
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.entur.example.web;

import no.entur.logging.cloud.logback.logstash.test.CompositeConsoleOutputControl;
import no.entur.logging.cloud.logback.logstash.test.CompositeConsoleOutputControlClosable;
import org.entur.example.web.rest.MyEntity;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ActuatorTest {

@LocalServerPort
private int randomServerPort;

@Autowired
private TestRestTemplate restTemplate;

@Test
public void useHumanReadablePlainEncoderTest() {
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/health/readiness", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}

@Test
public void useHumanReadableJsonEncoderTest() throws InterruptedException {
try (CompositeConsoleOutputControlClosable c = CompositeConsoleOutputControl.useHumanReadableJsonEncoder()) {
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/health/readiness", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
}

@Test
public void useMachineReadableJsonEncoder() throws InterruptedException {
try (CompositeConsoleOutputControlClosable c = CompositeConsoleOutputControl.useMachineReadableJsonEncoder()) {
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/health/readiness", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 13 additions & 1 deletion guides/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,19 @@ testImplementation ("no.entur.logging.cloud:request-response-spring-boot-starter
```
</details>

By default [certain OpenAPI and actuator endpoints](../gcp/request-response-spring-boot-starter-gcp-web/src/main/resources/logbook.gcp.web.properties) are excluded.
Some default Logbook excludes are recommended:

```
logbook:
predicate:
exclude:
- path: /actuator/**
- path: /favicon.*
- path: /v2/api-docs/**
- path: /v3/api-docs/**
- path: /metrics
- path: /swagger
```

Adjust the logger using

Expand Down

0 comments on commit 824f224

Please sign in to comment.