Mailing List webobjects-dev@wocommunity.org Message #105
From: Paul Hoadley <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Log4J 2.x
Date: Mon, 22 Mar 2021 12:06:47 +1030
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
On 18 Mar 2021, at 12:31 pm, Paul Hoadley <webobjects-dev@wocommunity.org> wrote:

The answer here is "yes", though it probably depends on your definition of "pain free".

The pain continued:

4. If you deploy with JavaMonitor, WOOutputPath gets set to provide diversion of console output to a file. This causes WOApplication to call System.setOut() and System.setErr(), but this happens after your ConsoleAppender has been set up. ERXApplication solves this for Log4J 1.x by "resetting" all of the ConsoleAppenders it can find in ERXApplication(). The Log4J 2.x solution is slightly more convenient, though took me a while to find. When you set up your ConsoleAppender, set follow=true:

app.logging.appender.console.type=Console
app.logging.appender.console.target=SYSTEM_OUT
app.logging.appender.console.name=STDOUT
app.logging.appender.console.follow=true

(Again, 'app.logging.' there is custom prefix, meaningful only to my custom ConfigurationFactory.) For whatever reason, the default for 'follow' is false, which causes the appender's output to be dropped on the floor after WOApplication calls System.setOut().

I think this should be enough to get anyone interested in Log4J 2.x off the starting block. Let me know if you want more detail.


-- 
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster