0

I have the following maven configuration:

        <dependency>
            <groupId>org.tinylog</groupId>
            <artifactId>slf4j-tinylog</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.tinylog</groupId>
            <artifactId>tinylog-api</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.tinylog</groupId>
            <artifactId>tinylog-impl</artifactId>
            <version>2.2.0</version>
        </dependency>

My Java program is the following:

    public static void main(final String[] args)
    {
        Configuration.set("w1", "console");
        Configuration.set("w1.tag", "SYSTEM");
        Configuration.set("w1.format", "SYSTEM: {message}");

        Configuration.set("w2", "console");
        Configuration.set("w2.tag", "-");
        Configuration.set("w2.format", "DEFAULT: {message}");

        final org.slf4j.Logger log = LoggerFactory.getLogger(MyLogging.class);
        log.info("Output for slf4j");
        Logger.tag("SYSTEM").info("Output for SYSTEM");
        Logger.info("Output for Default");
    }

The result is the following:

2020-10-31 11:07:32 [main] de.MyLogging.main()
INFO: Output for slf4j
2020-10-31 11:07:32 [main] de.MyLogging.main()
INFO: Output for SYSTEM
2020-10-31 11:07:32 [main] de.MyLogging.main()
INFO: Output for Default

It seems that the configuration is not taken at all.
I would have expected the following output:

DEFAULT: Output for slf4j
SYSTEM: Output for SYSTEM
DEFAULT: Output for Default

What is wrong with my code?

Christof Nasahl
  • 229
  • 3
  • 6

1 Answers1

1

Configuration.set("w1", "console") can't work. You need to rename "w1" into "writer1" and "w2" into "writer2". All writer properties have to start with the prefix "writer".

See the writer section in the official tinylog documentation for more details: https://tinylog.org/v2/configuration/#writers

Martin
  • 598
  • 1
  • 4
  • 27
  • Hi Martin, thanks a lot. This solves most of my issues. This only thing that is open is, that the slf4j logger writes ``` [main] INFO de.MyLogging - Output for slf4j ``` So it doesn't match with the default logger. Do you know how to achieve this? – Christof Nasahl Oct 31 '20 at 22:24
  • No I solved also the slf4j issue. A dependen module had a dependency to slf4j-simple – Christof Nasahl Oct 31 '20 at 22:39