I'm working on logger implementation and trying to print logger statements in a different pattern using an ERROR level log.
This is the XML config using for printing loggers. Is there any way to add multiple patterns and print the statements based on condition.
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME:-logs}/${LOG_FILE_NAME:-eportal-daas}.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger - %M - %L :[trackId=%X{trackId}]|uuid=%uuid|accountName=%X{accountName}|appName=%X{appName}|userName=%X{userName}|exceptionIssueCode=%expRoot|
:errorMessage=%msg
:stackTrace=%ex %n
</Pattern>
</encoder>
</appender>
Below is the sample statement using the java logger code
logger.error("********* Application Started Successfully *********");
2020-01-29 13:14:00 ERROR [main] com.apptium.Application - main - 64 :[trackId=]|uuid=66d1caaa-17ae-46c9-abf2-28f0da789353|accountName=|appName=|userName=|exceptionIssueCode=EP03NANIL -> UNEXPECTED ERROR|
:errorMessage=********* Application Started Successfully *********
:stackTrace=
Technically speaking, this does not error message. The root level is configured as an ERROR. I need to print in a different pattern. I'm using slf4j.