Answer the question
In order to leave comments, you need to log in
How to make 2 root appenders in log4j2?
Good day. I'm trying log4j2.
The task is to log all errors in 2 places: the console and the database (I wrote my appender).
I try like this, but it only logs to the last appender:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="bestapp">
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<MysqlAppender name="MYSQL"/>
</Appenders>
<Loggers>
<Root level="ERROR">
<AppenderRef ref="CONSOLE" />
</Root>
<Root level="ERROR">
<AppenderRef ref="MYSQL" />
</Root>
</Loggers>
</Configuration>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question