Hi, I’m working in aproject where I need to log same information in different log files.

 

I have 2 different Appenders, but I need to use only one custom Layout to avoid computing the same information twice

Is there a way to do so? 2 Appenders but only 1 executing layout?

 

Also, I'm trying to use a Pattern with a custom Layout, but either I get the pattern executed or the Layout,  but not both. How could I get both to work?

 

This is an example of the configuration of my logback.xml file

 

<conversionRule conversionWord="OnePattern"

               converterClass="OnePattern" />

 

<appender name="OneAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">

               <File>...</File>

               <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">

                              <pattern>%-6OnePattern %nopex%n</pattern>

                              <layout class="CustomLayout">

                              </layout>

               </encoder>

</appender>

 

Thanks in advance

 

Gustavo Arriazu