Tinylog Singlelevel-CW Extension

A Tinylog console writer extension to restrict writers to single log levels (e.g. for level-specific colored logs).

License

License

Categories

Categories

tinylog Application Layer Libs Logging
GroupId

GroupId

com.github.tobiasrm
ArtifactId

ArtifactId

tinylog-singlelevel-cw
Last Version

Last Version

1.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

Tinylog Singlelevel-CW Extension
A Tinylog console writer extension to restrict writers to single log levels (e.g. for level-specific colored logs).
Project URL

Project URL

https://github.com/tobiasrm/tinylog-singlelevel-cw
Source Code Management

Source Code Management

https://github.com/tobiasrm/tinylog-singlelevel-cw/tree/master

Download tinylog-singlelevel-cw

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.tobiasrm/tinylog-singlelevel-cw/ -->
<dependency>
    <groupId>com.github.tobiasrm</groupId>
    <artifactId>tinylog-singlelevel-cw</artifactId>
    <version>1.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.tobiasrm/tinylog-singlelevel-cw/
implementation 'com.github.tobiasrm:tinylog-singlelevel-cw:1.3.1'
// https://jarcasting.com/artifacts/com.github.tobiasrm/tinylog-singlelevel-cw/
implementation ("com.github.tobiasrm:tinylog-singlelevel-cw:1.3.1")
'com.github.tobiasrm:tinylog-singlelevel-cw:jar:1.3.1'
<dependency org="com.github.tobiasrm" name="tinylog-singlelevel-cw" rev="1.3.1">
  <artifact name="tinylog-singlelevel-cw" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.tobiasrm', module='tinylog-singlelevel-cw', version='1.3.1')
)
libraryDependencies += "com.github.tobiasrm" % "tinylog-singlelevel-cw" % "1.3.1"
[com.github.tobiasrm/tinylog-singlelevel-cw "1.3.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.tinylog : tinylog jar 1.3.1

Project Modules

There are no modules declared in this project.

tinylog singlelevel cw

A tinylog console writer extension to restrict writers to single log levels.

Features

The singlelevel-cw extends tinylog with the singlelevel-console parameter to restrict log outputs to the corresponding level. This supports debugging by defining multiple writers and print exactly the log-levels you need (e.g. traces, warnings, and errors).

   tinylog.writer              = singlelevel-console 
   tinylog.writer.singlelevel  = <true|false>

Example

The following screenshot shows the example where messages are logged to all log-levels (see Main.java) but the singlelevel-cw prints only the log-levels trace, warn and error are printed (here in Eclipse using the 'err ' stream for warn/error). This is realized by defining multiple writers, one per log-level and all restricted to the corresponding level, but activating only the needed ones.

You can reproduce the example by running mvn clean install and then java -jar target/tinylog-singlelevel-cw-1.3.1-executable.jar.

Maven artifact

Add the following dependency to use the singlelevel-cw in your maven project:

<dependency>
	<groupId>com.github.tobiasrm</groupId>
	<artifactId>tinylog-singlelevel-cw</artifactId>
	<version>1.3.1</version>
</dependency>

Comments

  • Versioning. The versioning (see pom.xml) uses the original tinylog versions, e.g. tinylog-singlelevel-cw in version 1.3.1 uses tinylog v1.3.1. If needed, you may simply exclude it and use another tinylog version.
  • Patched Configuration class. The singlelevel-cw implements the tinylog writer interface and is based on the tinylog consolewriter implementation. However, as the original tinylog Configuration does not provide the access on writer specific levels, a patch is provided with this project. The modifications are highlighted in the screenshots one and two. Of course, feel invited to diff with the original version.

Other tinylog writer extensions

See also my other tinylog writer extension projects:

  • tinylog-coloredconsole for colored log-level and arbitrary source-code generated data through custom tags.
  • tinylog-tagging-filewriter extension to remove custom strings (e.g. the tinylog-coloredconsole custom tags) before writing to file (based on filewriter)
  • tinylog-tagging-rollingfilewriter extension to remove custom strings (e.g. the tinylog-coloredconsole custom tags) before writing to file (based on rollingfilewriter)

Versions

Version
1.3.1