Re: ListAppender in parallel tests

2023-05-23 Thread Björn Kautler
> I came to the conclusion that there is no satisfactory solution to what I intend to do. Lies, lies, lies. Everything alternative facts. :-D Ralph had a simple but brilliant idea that he mentioned in LOG4J2-1094. I removed all the custom logic and instead now enable

Re: ListAppender in parallel tests

2023-05-08 Thread Volkan Yazıcı
Thanks so much for the elaborate investigation and taking the effort to share your findings with us. I want to participate in this therapy session. I learnt the hard way that one should test the logging behaviour of a certain class. That is, the logging behaviour of subject should be a part of

Re: ListAppender in parallel tests

2023-05-05 Thread Björn Kautler
Hi Thanks for all the hints so far. I had some time to revisit this topic recently. After much blood, sweat and tears (trying out many things, poking around, rethinking things, ...), I came to the conclusion that there is no satisfactory solution to what I intend to do. I'll describe in more

Re: ListAppender in parallel tests

2022-06-07 Thread Matt Sicker
Using the LoggerContextResolver extension, you can indeed get a per-test LoggerContext, but without a corresponding ContextSelector plugin to go with it, you'll have to use JUnit's parameter resolvers to get the Logger or LoggerContext rather than using LogManager. While that pattern works fine in

Re: ListAppender in parallel tests

2022-06-05 Thread Piotr P. Karwasz
Hi, Björn, On Wed, 13 Apr 2022 at 17:46, Björn Kautler wrote: > > 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

Re: ListAppender in parallel tests

2022-06-05 Thread Björn Kautler
Thanks for the quick reply, but did you actually read my last E-Mail? I already looked at that code and had additional questions / uncertainties. Regards Björn - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org

Re: ListAppender in parallel tests

2022-06-05 Thread Matt Sicker
See https://github.com/apache/logging-log4j2/blob/master/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/LoggerContextResolver.java for the JUnit 5 extension code. If you combine this with a ContextSelector plugin that selects the LoggerContext based on an

Re: ListAppender in parallel tests

2022-06-05 Thread Björn Kautler
Matt Sicker wrote: > If you look at our LoggerContextResolver JUnit 5 extension > code (more so in master than in release-2.x as the latter is an older > version of the former), you'll see how you can essentially use a > LoggerContext per test class or test instance (at least that's where > it

Re: ListAppender in parallel tests

2022-06-05 Thread Volkan Yazıcı
As Ralph has indicated, the best approach would be to create a new `LoggerContext` for each test verifying the logging behavior. `LoggerContextRule` in the sources might be a good starting point for you. I am actually interested in your feedback, if you happen to use it somehow. We might consider

Re: ListAppender in parallel tests

2022-06-03 Thread Matt Sicker
I'd imagine that the overhead of a LoggerContext per test would be fairly low as long as you're not configuring hundreds of loggers in each test. If you look at our LoggerContextResolver JUnit 5 extension code (more so in master than in release-2.x as the latter is an older version of the former),

Re: ListAppender in parallel tests

2022-06-03 Thread Björn Kautler
Hi Ralph Sorry, I was distracted by other things. > Ideally, parallel tests should use their own LoggerContext. But for the > ClassLoaderContextSelector (the default) this would require that each > test have its own ClassLoader. In reality it would be better to create a > ContextSelect for the

Re: ListAppender in parallel tests

2022-04-14 Thread Ralph Goers
Ideally, parallel tests should use their own LoggerContext. But for the ClassLoaderContextSelector (the default) this would require that each test have its own ClassLoader. In reality it would be better to create a ContextSelect for the framework you are using that keys off of something unique

Re: ListAppender in parallel tests

2022-04-13 Thread Matt Sicker
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