journald formatter

JUL Formatter which sends logs to journald with proper log level

License

License

Categories

Categories

ORM Data
GroupId

GroupId

ru.r2cloud
ArtifactId

ArtifactId

journald-formatter
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

journald formatter
JUL Formatter which sends logs to journald with proper log level
Project URL

Project URL

https://github.com/dernasherbrezon/journald-formatter
Source Code Management

Source Code Management

https://github.com/dernasherbrezon/journald-formatter

Download journald-formatter

How to add to project

<!-- https://jarcasting.com/artifacts/ru.r2cloud/journald-formatter/ -->
<dependency>
    <groupId>ru.r2cloud</groupId>
    <artifactId>journald-formatter</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/ru.r2cloud/journald-formatter/
implementation 'ru.r2cloud:journald-formatter:1.0'
// https://jarcasting.com/artifacts/ru.r2cloud/journald-formatter/
implementation ("ru.r2cloud:journald-formatter:1.0")
'ru.r2cloud:journald-formatter:jar:1.0'
<dependency org="ru.r2cloud" name="journald-formatter" rev="1.0">
  <artifact name="journald-formatter" type="jar" />
</dependency>
@Grapes(
@Grab(group='ru.r2cloud', module='journald-formatter', version='1.0')
)
libraryDependencies += "ru.r2cloud" % "journald-formatter" % "1.0"
[ru.r2cloud/journald-formatter "1.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

About Build Status Quality Gate Status

This project provides special JUL formatter. It will format log levels as numbers instead of strings. These numbers are from syslog format. Using these numbers could help you assign proper log level in journald. See the example below.

Example configuration

Here is example configuration:

java.util.logging.ConsoleHandler.formatter=ru.r2cloud.logging.JournaldFormatter
java.util.logging.JournaldFormatter.format=<%4$s>%5$s%6$s [%2$s]%n

It looks like a normal SimpleFormatter configuration. The trick is in <%4$s>. When java process outputs log entries with such prefix, journald can parse them and assign proper level. Later on, these log entries could be searched, parsed, analyzed via journalctl:

journalctl -u myservice -p err -n 20 

Versions

Version
1.0