I have this appender in my logback.xml
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>logFile.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>5</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{35} - %msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="FILE" />
</root>
So at the moment I am saving all my logs to one file. How can I make it like, one file saves only error logs and other saves all other?
And I want to keep using only 1 instance of logger in my code, something like this:
private static final Logger log = LoggerFactory.getLogger(Main.class);
This is what I do for Jboss but I guess you'll get the solution.
Create a dedicated appender for error.log as follows,
Create an appender for the rest of them
Then create specific categories for both the above
Started looking for logback categories, found filters.
Just add filter description to your appender: