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 Travis Spencer <tr...@curity.io> on 2021/10/01 08:02:53 UTC

Re: Unit testing custom log event factory fails intermittently

On Thu, Sep 30, 2021 at 9:29 AM Travis Spencer <tr...@curity.io> 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.

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