Glassfish and log4j - java

I am trying to deploy 2 servlets in glassfish with log4j library.
I have no problems in tomcat. Each servlet writes in its own file but in tomcat, I found this guide https://blogs.oracle.com/naman/entry/configure_log4j_for_use_in to configure and support log4f library.
I got the first servlet working with it. And it writes logs in its log file. But whenever I deploy the secod servlet, I don't see its logs. The first one keeps writing in its own file but the second one not.
I modify the logback.xml file included in config folder to include both files and all packages but it seems to ignore it. This is my logback.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.lordofthejars.foo" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<appender name="SERVER-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->0
<fileNamePattern>/root/glassfish4/glassfish/domains/domain1/logs/serverregister-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- keep 7 days' worth of history -->
<maxHistory>7</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<MaxFileSize>512MB</MaxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<append>true</append>
<encoder>
<pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%p] %logger{5}:%L - %msg%n</pattern>
</encoder>
</appender>
<appender name="REGMAN-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<!--<fileNamePattern>${catalina.home}/logs/registermanager-%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
<fileNamePattern>/root/glassfish4/glassfish/domains/domain1/logs/registermanager-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- keep 7 days' worth of history -->
<maxHistory>7</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<MaxFileSize>512MB</MaxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<append>true</append>
<encoder>
<pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%p] %logger{5}:%L - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.eu.iotapi.handlers.AuthenticationGatewayHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.handlers.AuthenticationHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.handlers.DeviceValidationHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.handlers.EventValidationHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.handlers.GatewayValidationHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.handlers.ObservationValidationHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.PublicationsResource" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.RegisterDeviceOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.RegisterGatewayOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.RegistrationResource" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.SubmitEventOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.SubmitObservationOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.uns.device.RegisterDeviceHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.uns.events.SubmitEventsHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.uns.device.RegisterGatewayHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.uns.observations.SubmitObservationsHandler" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.iotapi.resources.DeviceTranslator" level="DEBUG" additivity="false">
<appender-ref ref="SERVER-FILE"/>
</logger>
<logger name="com.eu.registermanager.eventbroker.device.registration.DeviceRegistrationHandler" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.eventbroker.gateway.GatewayRegistrationHandler" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.handlers.AuthenticationGatewayHandler" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.handlers.AuthenticationHandler" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.resources.RegisterDeviceOnEventBrokerOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.resources.RegisterGatewayOnEventBrokerOnBackground" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<logger name="com.eu.registermanager.resources.RegisterResource" level="DEBUG" additivity="false">
<appender-ref ref="REGMAN-FILE"/>
</logger>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

Related

Logback unable to log in debug

I have a bit problem with a logback configuration, all of my --> log.debug("one log")
of my application aren't written is my debug.log file ... do you know why ?
bellow my logback configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<property name="LOG_PATH" value="/home/log/company"/>
<appender name="trafic" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/trafic.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]|%-5level|%thread|%logger.%method%cyan(\(%line\)): --- %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>30</maxHistory>
<totalSizeCap>50MB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<fileNamePattern>${LOG_PATH}/trafic/year=%d{yyyy, aux}/month=%d{MM, aux}/day=%d{dd,
aux}/trafic.%d{yyyy-MM-dd}.log
</fileNamePattern>
</rollingPolicy>
</appender>
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/debug.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]|%-5level|%thread|%logger.%method%cyan(\(%line\)): --- %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>30</maxHistory>
<totalSizeCap>50MB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<fileNamePattern>${LOG_PATH}/debug/year=%d{yyyy, aux}/month=%d{MM, aux}/day=%d{dd,
aux}/debug.%d{yyyy-MM-dd}.log
</fileNamePattern>
</rollingPolicy>
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/error.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]|%-5level|%thread|%logger.%method%cyan(\(%line\)): --- %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>30</maxHistory>
<totalSizeCap>50MB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<fileNamePattern>${LOG_PATH}/error/year=%d{yyyy, aux}/month=%d{MM, aux}/day=%d{dd,
aux}/error.%d{yyyy-MM-dd}.log
</fileNamePattern>
</rollingPolicy>
</appender>
<appender name="access" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/access.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]|%-5level|%thread|%logger.%method%cyan(\(%line\)): --- %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>30</maxHistory>
<totalSizeCap>50MB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<fileNamePattern>${LOG_PATH}/access/year=%d{yyyy, aux}/month=%d{MM, aux}/day=%d{dd,
aux}/access.%d{yyyy-MM-dd}.log
</fileNamePattern>
</rollingPolicy>
</appender>
<logger name="fr.company" level="ERROR" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="fr.company" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="fr.company" level="DEBUG" additivity="false">
<appender-ref ref="debug"/>
</logger>
<logger name="fr.company" level="INFO" additivity="false">
<appender-ref ref="trafic"/>
</logger>
<logger name="org.apache.activemq" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="org.springframework" level="INFO" additivity="false">
<appender-ref ref="access"/>
<appender-ref ref="trafic"/>
</logger>
<logger name="springfox.documentation" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="org.hibernate" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="com.zaxxer" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<root>
<appender-ref ref="trafic"/>
<appender-ref ref="access"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
And my dependencies:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
And the logger declaration/utilization:
#Slf4j
#Service
public class EventProcessor {
public EventProcessor() {
log.info("Event initialized with '{}' uuid received", getEventUuid());
log.debug("Event initialized with '{}' uuid received", getEventUuid());
}
Do you know why, the INFO lines are correctly writted in debug.log and not DEBUG lines ? ...
thank you very much
<logger name="fr.company" level="ERROR" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="fr.company" level="WARN" additivity="false">
<appender-ref ref="error"/>
</logger>
<logger name="fr.company" level="DEBUG" additivity="false">
<appender-ref ref="debug"/>
</logger>
<logger name="fr.company" level="INFO" additivity="false">
<appender-ref ref="trafic"/>
</logger>
You are configuring the same logger four times.
Only the last configuration will be effective (which sets the log level to INFO).
What you seem to want is have the logger at DEBUG, add all appenders to it, and then filter again in the appenders to control the output (which you are already doing).
<logger name="fr.company" level="DEBUG" additivity="false">
<appender-ref ref="error"/>
<appender-ref ref="debug"/>
<appender-ref ref="trafic"/>
</logger>

How can i avoid the queries of my spring-boot with hibernate app will be written to console or file?

I have an app written in spring-boot.
I have the following files:
application.properties
spring.main.banner-mode=off
debug=false
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.use_sql_comments=false
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProfile name="dev">
<property name="LOGS" value="...." />
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</layout>
</appender>
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS}/signing-dev.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOGS}/archived/signing-dev-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="info">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</root>
<logger name="[mypackage]" level="error" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
<logger name="level.com.zaxxer" level="error" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
<logger name="org.hibernate" level="error" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
<logger name="org.thymeleaf" level="error" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
<logger name="org.springframework.security" level="error" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
</springProfile>
</configuration>
I want to avoid that my hibernate queries will be written to console or file, but they are written like this:
Hibernate: select employeead0_.id as id1_0_0_, employeead0_.type as type2_0_0_ from employee_admin employeead0_ where employeead0_.id=?
How can i configure logback to avoid this?
try add this to application.properties:
#show sql statement
logging.level.org.hibernate.SQL=error
#show sql values
logging.level.org.hibernate.type.descriptor.sql=error

Jhipster Spring Boot Log setup

I create app using JHipster. Is there any simple way to configure application to create log files for each separate day ? I tried everything in one file but its getting to big and its not good practice. I did that by adding this part on the end of my server start command :
>> console.log &
Logback-spring.xml :
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/log-file.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<charset>utf-8</charset>
<Pattern>%d %-5level [%thread] %logger{0}: %msg%n</Pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>512</queueSize>
<appender-ref ref="FILE"/>
</appender>
<logger name="javax.activation" level="WARN"/>
<logger name="javax.mail" level="WARN"/>
<logger name="javax.xml.bind" level="WARN"/>
<logger name="ch.qos.logback" level="WARN"/>
<logger name="com.codahale.metrics" level="WARN"/>
<logger name="com.ryantenney" level="WARN"/>
<logger name="com.sun" level="WARN"/>
<logger name="com.zaxxer" level="WARN"/>
<logger name="io.undertow" level="WARN"/>
<logger name="io.undertow.websockets.jsr" level="ERROR"/>
<logger name="org.ehcache" level="WARN"/>
<logger name="org.apache" level="WARN"/>
<logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
<logger name="org.bson" level="WARN"/>
<logger name="org.elasticsearch" level="WARN"/>
<logger name="org.hibernate.validator" level="WARN"/>
<logger name="org.hibernate" level="WARN"/>
<logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
<logger name="org.springframework" level="WARN"/>
<logger name="org.springframework.web" level="WARN"/>
<logger name="org.springframework.security" level="WARN"/>
<logger name="org.springframework.cache" level="WARN"/>
<logger name="org.thymeleaf" level="WARN"/>
<logger name="org.xnio" level="WARN"/>
<logger name="springfox" level="WARN"/>
<logger name="sun.rmi" level="WARN"/>
<logger name="liquibase" level="WARN"/>
<logger name="LiquibaseSchemaResolver" level="INFO"/>
<logger name="sun.rmi.transport" level="WARN"/>
<!-- https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090 -->
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
Configure a RollingFileAppender in logback-spring.xml rather than using a ConsoleAppender. See https://logback.qos.ch/manual/appenders.html#RollingFileAppender
The logback-spring.xml generated by JHipster contains all the prod configuration, you just have to uncomment it.
<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<charset>utf-8</charset>
<Pattern>%d %-5level [%thread] %logger{0}: %msg%n</Pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>512</queueSize>
<appender-ref ref="FILE"/>
</appender>
<root level="${logging.level.root}">
<appender-ref ref="ASYNC"/>
</root>
you can use this code in your own logback.xml
<appender name="dailyRollingFileAppenderError" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${DEV_HOME}/error.log</File>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d [%-5level] %logger{36} - %msg%n</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<FileNamePattern>${DEV_HOME}/error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="error">
<appender-ref ref="dailyRollingFileAppenderError"/>
</root>

logback is ignoring springProfile tag

I want to logback to print log messages in file when profile is not 'local', if profile is local then I want it to print to console and as well file.
my logback.xml is as following.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- logger name="org.springframework.jdbc.core" level="debug" -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i</fileNamePattern>
<!-- each file should be at most 10MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>10MB</maxFileSize>
<maxHistory>10</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-4relative [%thread] %-5level %logger{35}.%M %line - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.mycom.name" level="info" additivity="false">
<appender-ref ref="FILE"/>
<springProfile name="local">
<appender-ref ref="STDOUT"/>
</springProfile>
</logger>
<logger name="com.mycom.name" level="debug" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<!--
<root level="info">
<springProfile name="local">
<appender-ref ref="STDOUT"/>
</springProfile>
<appender-ref ref="FILE"/>
</root>
<springProfile name="local">
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</springProfile>
-->
<root level="error">
<appender-ref ref="FILE" />
</root>
</configuration>
I see that its ignoring the springProfile tag and not printing to console at all.
OR am I missing something ??

Logback and different levels

There 3 appenders: STDOUT, FILE-AUDIT and FILE-ERROR. How to log all messages to STDOUT and FILE_AUDIT(including errors), but errors messages dublicate in FILE-ERROR. Part of my logback.xml:
<logger level="all"
additivity="true">
<appender-ref ref="FILE-AUDIT" />
<appender-ref ref="STDOUT" />
</logger>
<root level="error">
<appender-ref ref="FILE-ERROR" />
</root>
You should define your FILE-ERROR appender with a ThresholdFilter:
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>[...]</file>
<!-- [...] -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
Then, simply add all your appenders to root logger:
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE-AUDIT" />
<appender-ref ref="FILE-ERROR" />
</root>
This way, STDOUT and FILE-AUDIT contain all the messages, but FILE-ERROR only contains error messages.

Categories