You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Marco Herrn <ml...@mherrn.de> on 2018/10/23 14:01:50 UTC

Multiple ListAppenders in YAML config

Hi,

I am preparing a pull request for LOG4J2-2403 and modified an existing
Unit-Test that has its configuration in YAML format. I added a second
ListAppender, but this causes the Unit test to behave strangely.

It seems that, since I have two ListAppenders now, the sequence numbers are
shared between the Appenders. So one of them gets the sequence number 1, 3,
5, 7, 9 and the other gets 2, 4, 6, 8, 10. Is there a way to avoid this?

The seconds problem is that the sequence number is not reset between the
tests. I do not know how to do this with the LoggerContextRule.


The Unit-Test I have modified is SequenceNumberPatternConverterTest.
Please find attached the modified Test class and its corresponding YAML-File.

Any suggestions on how to solve these problems? I could create a seconds
Unit test class, but I would rather use the same because they actually test
exactly the same functionality, only with different patterns.


Best regards
Marco


Re: Multiple ListAppenders in YAML config

Posted by Marco Herrn <ml...@mherrn.de>.
Well,

I have now split those tests into two separate Test classes.
I have prepared a pull request for it. It would be great if someone reviews
it and include it in the next release of Log4j2.

JIRA Ticket:  https://issues.apache.org/jira/browse/LOG4J2-2403
Pull Request: https://github.com/apache/logging-log4j2/pull/224

Best regards
Marco

On Tue, Oct 23, 2018 at 04:01:50PM +0200, Marco Herrn wrote:
> Hi,
> 
> I am preparing a pull request for LOG4J2-2403 and modified an existing
> Unit-Test that has its configuration in YAML format. I added a second
> ListAppender, but this causes the Unit test to behave strangely.
> 
> It seems that, since I have two ListAppenders now, the sequence numbers are
> shared between the Appenders. So one of them gets the sequence number 1, 3,
> 5, 7, 9 and the other gets 2, 4, 6, 8, 10. Is there a way to avoid this?
> 
> The seconds problem is that the sequence number is not reset between the
> tests. I do not know how to do this with the LoggerContextRule.
> 
> 
> The Unit-Test I have modified is SequenceNumberPatternConverterTest.
> Please find attached the modified Test class and its corresponding YAML-File.
> 
> Any suggestions on how to solve these problems? I could create a seconds
> Unit test class, but I would rather use the same because they actually test
> exactly the same functionality, only with different patterns.
> 
> 
> Best regards
> Marco
> 


> Configuration:
>   status: OFF
>   name: SequenceNumberPatternConverterTest
> 
>   Appenders:
>     List:
>       - name: List
>         PatternLayout:
>           pattern: '%sn'
> 
>       - name: Padded
>         PatternLayout:
>           pattern: '%03sn'
> 
>   Loggers:
>     Root:
>       level: INFO
>       AppenderRef:
>         - ref: List
>         - ref: Padded
> 

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org