Tinylog Tagging FileWriter Extension

A Tinylog filewriter extension that enables the replacement of source-code generated custom tags.

License

License

Categories

Categories

tinylog Application Layer Libs Logging
GroupId

GroupId

com.github.tobiasrm
ArtifactId

ArtifactId

tinylog-tagging-filewriter
Last Version

Last Version

1.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

Tinylog Tagging FileWriter Extension
A Tinylog filewriter extension that enables the replacement of source-code generated custom tags.
Project URL

Project URL

https://github.com/tobiasrm/tinylog-tagging-filewriter
Source Code Management

Source Code Management

https://github.com/tobiasrm/tinylog-tagging-filewriter/tree/master

Download tinylog-tagging-filewriter

How to add to project

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

A tinylog filewriter extension to remove arbitrary data defined via custom tags from the log entry.

The main objective is the use in combination with tinylog-coloredconsole, which allows arbitrary colorized logs through custom tags. With tinylog-tagging-filewriter, you can remove (or replace) those tags before writing the log to file.

Features

The tinylog-tagging-filewriter extends tinylog with the tagging-filewriter file writer. It allows you to define up to 10 custom tags (an arbitrary string), which are replaced with the corresponding custom parameter. Thus, you can generate some tags in your source-code to further processing (e.g. via the tinylog-coloredconsole) but replaced custom content for file writing.

The following listing outlines the defition of custom tags/parameters. The example will remove customTag1 and customTag2 before file writing (customTag2 via non-provided content, i.e. being empty, thus reducing config size), while customTag3 is replaced with "==3==".

DEFINITION:
   tinylog.writer               = tagging-filewriter
   tinylog.writer.customTag1    = <custom tag>
   tinylog.writer.customParam1  = <content to replace customTag1>
   
EXAMPLE:    
   tinylog.writer               = tagging-filewriter
   tinylog.writer.customTag1    = [[customTag1]]
   tinylog.writer.customParam1  = 
   tinylog.writer.customTag2    = [[customTag2]]
   #tinylog.writer.customParam2 = 
   tinylog.writer.customTag3    = [[customTag3]]
   tinylog.writer.customParam3  = ==3==
   < and so on ... up to 10 tag/param entries>

The following screenshots show the listing example with some lorem ipsum text (and those three tags).

Console output (sysout in eclipse):

Log file entry:

Try it out

You can reproduce the colored log demo by running mvn clean install and then java -jar target/tinylog-tagging-filewriter-1.3.1-executable.jar

Uncomment the desired logging of the main method and corresponding tinylog.properties config for the listed example.

Maven artifact

Add the following dependency to your pom.xml to use the tinylog-tagging-filewriter in your Maven project:

<dependency>
	<groupId>com.github.tobiasrm</groupId>
	<artifactId>tinylog-tagging-filewriter</artifactId>
	<version>1.3.1</version>
</dependency>

Note: To make sure your IDE takes all files into account (notably the TaggingFileWriter class), clean and rebuild your project.

Comments

  • Versioning. The versioning uses the original tinylog versions for clarity about the underlying libary, e.g. tinylog-tagging-filewriter in version 1.3.1 uses tinylog v1.3.1 (see pom.xml). If needed, you may simply exclude it and use another tinylog 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-rollingfilewriter extension to remove custom strings (e.g. the tinylog-coloredconsole custom tags) before writing to file (based on rollingfilewriter)
  • tinylog-singlelevel-cw for console writers being restricted to their levels (e.g. only print trace, warn and error) to support debugging

Versions

Version
1.3.1