Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 2.98 KB

README.md

File metadata and controls

43 lines (30 loc) · 2.98 KB

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)