Re: Unit testing custom log event factory fails intermittently

Travis Spencer <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CAEKOcs0o7jDFSfTx-qQLtWKYF-=f0AjCOWqqfMgB1uACON=q0g@mail.gmail.com>
On Thu, Sep 30, 2021 at 9:29 AM Travis Spencer <[email protected]> wrote:

> 2. Is there some other way to set the LogEventFactory besides a system
> property?

I did like this:

@BeforeClass
public static void beforeClass()
{
        _context.getConfiguration().getLoggers()
                .forEach((loggerName, loggerConfig) ->
                    loggerConfig.setLogEventFactory(
                        new MyGoodLogEventFactory()));
}

@ClassRule
public static LoggerContextRule _context = new
    LoggerContextRule("myGoodConfig.xml");

Tests pass fine now.
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.