Re: ListAppender in parallel tests

Matt Sicker <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CACmp6kq9wpVgzXoAozS+Twc5De0s7axwz8823cc4_u-jL0ig4Q@mail.gmail.com>
The main reason why ListAppender doesn't support concurrent tests is
essentially a chicken-or-the-egg scenario. While I'd love to be able
to enable concurrent tests in log4j-core, for example, there are so
many tests that aren't currently configured or written to work
concurrently, nobody got around to implementing concurrency support in
ListAppender to support such a use case. Updates to ListAppender (or
an additional appender supporting concurrency) would certainly be
welcomed as contributions!

On Wed, Apr 13, 2022 at 10:46 AM Björn Kautler <[email protected]> wrote:
>
> Hi
>
> I'm currently using ListAppender from log4j2-core-test, to test that
> the logging of the project does what it should do.
> For that I configured a ListAppender in the log4j2 config file that is
> used for the tests.
> In a custom global Spock extension (the test framework I use), I
> retrieve the appender
> using ListAppender.getListAppender and call clear() on it before an
> iteration starts,
> so I only get the logs written during that test and it also does not
> overflow the RAM.
>
> Now my problem is, that I'd like to enable parallel execution of the
> tests which is new in Spock 2.x.
> But the ListAppender naturally does not like that, as it is the same
> for the whole JVM.
>
> I looked into the LoggerContextRule whether I find something useful there,
> but - please correct me if I'm wrong - as far as I have seen it also
> is not capable of parallel execution
> as it uses system properties and static state, so parallel tests would
> also overwrite each other I guess.
>
> Is there something that could be used that better supports parallel execution?
> Would maybe a ThreadLocalListAppender help that has thread local
> fields for events, messages, and data?
> Or something else that is available?
>
> Regards
> Björn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.