1

I am using https://mvnrepository.com/artifact/org.tinylog/tinylog-api/2.2.0 in our project.

I can configure my writer format the following way:

Configuration.set("writer", "console");
Configuration.set("writer.format", "{level}: {class-name}.{method}(): {message}");

But now I need a different output format for some loggers.

Is this possible with tinylog? If yes, can someone provide a short example how to do this?

Thanks ...

Christof Nasahl
  • 229
  • 3
  • 6

1 Answers1

0

You can use tags (https://tinylog.org/v2/configuration/#tags):

Configuration.set("writer1", "console");
Configuration.set("writer1.tag", "A, B");
Configuration.set("writer1.format", "{class-name}: {message}");

Configuration.set("writer2", "console");
Configuration.set("writer2.tag", "C");
Configuration.set("writer2.format", "{level}: {message}");

Tagged loggers can be created via TaggedLogger logger = Logger.tag("A").

Martin
  • 598
  • 1
  • 4
  • 27
  • Thanks a lot. That was the hint in the right direction. Actually I realized that I also use slf4j loggers, but in the end I managed to map them to my standard logger. – Christof Nasahl Oct 31 '20 at 09:26
  • You can also use markers for SLF4J loggers. These makers will be mapped to tinylog's tags. – Martin Oct 31 '20 at 12:35