Getting Started
What is Penna?
Penna is a fast and lightweight slf4j implementation that writes structured JSON log messages to stdout. You can read more here.
When should I use Penna?
Penna is specially useful for when you run you applications on docker containers or kubernetes pods and your log is captured from stdout to a log aggregator like loki or the elastic stack.
Adding Penna to your project
- Add the latest version of
penna-core
to your dependency manager.
// gradle
runtimeOnly 'com.hkupty.penna:penna-core:0.8.1'
<!-- maven -->
<dependency>
<groupId>com.hkupty.penna</groupId>
<artifactId>penna-core</artifactId>
<version>0.8.1</version>
</dependency>
- Enjoy! Penna comes with sane defaults so no initial configuration is needed
What if I want to change the configuration?
Then you need to add penna-yaml-config
to your project, alongside jackson-dataformat-yaml:
// gradle
runtimeOnly 'com.hkupty.penna:penna-yaml-config:0.8.1'
// penna-yaml-config is a thin layer and uses a yaml parsing libray under the hood.
// You can chose among jackson, snakeyaml (yaml 1.1) or snakeyaml engine (yaml 1.2)
// Jackson
runtimeOnly 'com.fasterxml.jackson.core:jackson-core:2.17.0'
runtimeOnly 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
runtimeOnly 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.0'
// Snakeyaml
runtimeOnly 'org.yaml:snakeyaml:2.2'
// Snakeyaml engine
runtimeOnly 'org.snakeyaml:snakeyaml-engine:2.7'
<!-- maven -->
<dependency>
<groupId>com.hkupty.penna</groupId>
<artifactId>penna-yaml-config</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>$jacksonVersion</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>$jacksonVersion</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>$jacksonVersion</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.snakeyaml</groupId>
<artifactId>snakeyaml-engine</artifactId>
<version>2.7</version>
</dependency>
And then you can configure a resources/penna.yaml
file like this:
|
|
Can I change more parameters in the configuration?
As mentioned before, penna comes with a set of good defaults so you don’t have to worry about them, but if you really want to tweak some parameters, you can.
|
|