-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable logstash-formatted JSON logging to the console
To enable JSON logging, the applications must be run with the `json-logs` Spring profile. The default configuration in the Docker images at `/etc/geoserver/` include logback and rabbitmq config files for JSON logging: * `logback-spring.xml` defines a logstash compatible JSON console appender for spring boot apps. This default file is identical to the one included in the applications classpath already. In order to use this one, for example, may it require some tunning, the application must be run with `-Dlogging.config=file:/etc/geoserver/logback-spring.xml`, or any other location where the xml config file is placed. * A sample `rabbitmq.conf` file declaring console json logging output for rabbitmq. Must be mounted at `/etc/rabbitmq/rabbitmq.conf`, or use it as a guideline to enhance rabbitmq's configuration.
- Loading branch information
Showing
7 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Observability starter | ||
|
||
Spring-Boot starter project to treat application observability (logging, metrics, tracing) as a cross-cutting concern. | ||
|
||
## Dependency | ||
|
||
Add dependency | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.geoserver.cloud</groupId> | ||
<artifactId>gs-cloud-starter-observability</artifactId> | ||
<version>${project.verison}</version> | ||
</dependency> | ||
``` | ||
|
||
## Logstash formatted JSON Logging | ||
|
||
The `net.logstash.logback:logstash-logback-encoder` dependency allows to write logging entries as JSON-formatted objects in Logstash scheme. | ||
|
||
The application must be run with the `json-logs` Spring profile, as defined in [logback-spring.xml](src/main/resources/logback-spring.xml). |
17 changes: 17 additions & 0 deletions
17
src/starters/observability/src/main/resources/logback-spring.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<configuration> | ||
|
||
<springProfile name="default"> | ||
<include resource="org/springframework/boot/logging/logback/base.xml" /> | ||
</springProfile> | ||
|
||
<springProfile name="json-logs"> | ||
<appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="net.logstash.logback.encoder.LogstashEncoder" /> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="jsonConsoleAppender" /> | ||
</root> | ||
</springProfile> | ||
|
||
</configuration> |