RE: Issue after moving to log4j 2.19

2022-10-18 Thread Joan ventusproxy
Hi Ralph,

It's a tomcat related issue.

If I execute my application with the latest version of 8.5 series (8.5.83), it 
does not work.
Exactly the same using tomcat 8.5.39 works perfectly.

Thanks,

Joan.

-Original Message-
From: Ralph Goers  
Sent: Monday, October 17, 2022 5:28 PM
To: Log4J Users List 
Subject: Re: Issue after moving to log4j 2.19

This indicates that for some reason Log4j 2 is now initializing earlier - 
before your system property is being set.

Your solution gets the currently configured LoggerContext (presumably using the 
default configuration) and causes it to reconfigure using the new location.

Ralph

> On Oct 17, 2022, at 6:03 AM, Joan ventusproxy 
>  wrote:
> 
> Hello,
> 
> Solved ... I don't exactly understand why ... but solved.
> 
> I had to change my code in this way. Instead of:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
> 
> Now is:
> LoggerContext context = (LoggerContext) LogManager.getContext(false); 
> context.setConfigLocation("/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log
> 4j.xml");
> 
> this.systemLog = context.getLogger("LOGGER_SYSTEM");
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Joan ventusproxy 
> Sent: Monday, October 17, 2022 1:47 PM
> To: 'Log4J Users List' 
> Subject: RE: Issue after moving to log4j 2.19
> 
> Hello,
> 
> Investigating a little more ...
> 
> If I set the variable 
> -Dlog4j.configurationFile=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml 
> on the tomcat startup script, it works.
> 
> But setting this on my application, as we always did, it does not work any 
> more:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> The point is this is a simplified example, building this path is much more 
> complicated and it must be done at application level, not tomcat level.
> 
> By the way, our web.xml contains this:
> 
>  
>isLog4jContextSelectorNamed
>true
>  
> 
>  
>log4jContextName
>ventusproxy
>  
> 
> Thanks,
> 
> Joan.
> 
> 
> -Original Message-
> From: Joan ventusproxy 
> Sent: Sunday, October 16, 2022 9:03 PM
> To: 'Log4J Users List' 
> Subject: RE: Issue after moving to log4j 2.19
> 
> Is not this? (second gist):
> 
> DEBUG StatusLogger Watching configuration 
> '/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml' for lastModified 
> Sat Oct 15 21:55:38 UTC 2022 (1665870938000) DEBUG StatusLogger Apache 
> Log4j Core 2.19.0 initializing configuration 
> XmlConfiguration[location=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4
> j.xml]
> 
> Joan.
> 
> -Original Message-
> From: Ralph Goers 
> Sent: Sunday, October 16, 2022 2:44 AM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> In both of those log files Log4j is not seeing any value as being set of 
> log4j.configurationFile. It is ending up using the default configuration.
> 
> Ralph
> 
>> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>>  wrote:
>> 
>> Hi Piotr,
>> 
>> Thanks for your quick response.
>> 
>> Below two gists with the traces for both cases:
>> 
>> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
>> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c10
>> 8 
>> 17900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.tx
>> t
>> 
>> In this case logs are not created.
>> 
>> 
>> 2. Using "this.systemLog = 
>> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
>> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44
>> a 
>> 196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.tx
>> t
>> 
>> In this case logs are created and content is logged into them correctly, but 
>> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
>> 
>> 
>> The " log4j.configurationFile " variable is set in this way:
>> System.setProperty("log4j.configurationFile",
>> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
>> 
>> And tomcat starts with:
>> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLogge
>> r
>> ContextSelector
>> 
>> 
>> The point is that for years we have been running this without issues using 
>> point 1

Re: Issue after moving to log4j 2.19

2022-10-17 Thread Ralph Goers
This indicates that for some reason Log4j 2 is now initializing earlier - 
before your system property is being set.

Your solution gets the currently configured LoggerContext (presumably using the 
default configuration) and causes it to reconfigure using the new location.

Ralph

> On Oct 17, 2022, at 6:03 AM, Joan ventusproxy 
>  wrote:
> 
> Hello,
> 
> Solved ... I don't exactly understand why ... but solved.
> 
> I had to change my code in this way. Instead of:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
> 
> Now is:
> LoggerContext context = (LoggerContext) LogManager.getContext(false);
> context.setConfigLocation("/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> this.systemLog = context.getLogger("LOGGER_SYSTEM");
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Joan ventusproxy  
> Sent: Monday, October 17, 2022 1:47 PM
> To: 'Log4J Users List' 
> Subject: RE: Issue after moving to log4j 2.19
> 
> Hello,
> 
> Investigating a little more ...
> 
> If I set the variable 
> -Dlog4j.configurationFile=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml 
> on the tomcat startup script, it works.
> 
> But setting this on my application, as we always did, it does not work any 
> more:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> The point is this is a simplified example, building this path is much more 
> complicated and it must be done at application level, not tomcat level.
> 
> By the way, our web.xml contains this:
> 
>  
>isLog4jContextSelectorNamed
>    true
>  
> 
>  
>log4jContextName
>ventusproxy
>  
> 
> Thanks,
> 
> Joan.
> 
> 
> -Original Message-
> From: Joan ventusproxy  
> Sent: Sunday, October 16, 2022 9:03 PM
> To: 'Log4J Users List' 
> Subject: RE: Issue after moving to log4j 2.19
> 
> Is not this? (second gist):
> 
> DEBUG StatusLogger Watching configuration 
> '/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml' for lastModified Sat Oct 
> 15 21:55:38 UTC 2022 (1665870938000) DEBUG StatusLogger Apache Log4j Core 
> 2.19.0 initializing configuration 
> XmlConfiguration[location=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml]
> 
> Joan.
> 
> -Original Message-
> From: Ralph Goers 
> Sent: Sunday, October 16, 2022 2:44 AM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> In both of those log files Log4j is not seeing any value as being set of 
> log4j.configurationFile. It is ending up using the default configuration.
> 
> Ralph
> 
>> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>>  wrote:
>> 
>> Hi Piotr,
>> 
>> Thanks for your quick response.
>> 
>> Below two gists with the traces for both cases:
>> 
>> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
>> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c108
>> 17900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt
>> 
>> In this case logs are not created.
>> 
>> 
>> 2. Using "this.systemLog = 
>> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
>> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a
>> 196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt
>> 
>> In this case logs are created and content is logged into them correctly, but 
>> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
>> 
>> 
>> The " log4j.configurationFile " variable is set in this way:
>> System.setProperty("log4j.configurationFile", 
>> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
>> 
>> And tomcat starts with:
>> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLogger
>> ContextSelector
>> 
>> 
>> The point is that for years we have been running this without issues using 
>> point 1, without getting the context from the LogManager.
>> 
>> One more clue. As I said, this is not working fine on our new installation 
>> with Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same 
>> code running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle 
>> jdk 11 works perfectly, logs are created and the hazelcast logging is sent 
>> to the SYSTEM_LOG.
>

RE: Issue after moving to log4j 2.19

2022-10-17 Thread Joan ventusproxy
Hello,

Solved ... I don't exactly understand why ... but solved.

I had to change my code in this way. Instead of:
System.setProperty("log4j.configurationFile", 
"/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");

Now is:
LoggerContext context = (LoggerContext) LogManager.getContext(false);
context.setConfigLocation("/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");

this.systemLog = context.getLogger("LOGGER_SYSTEM");


Thanks,

Joan.

-Original Message-
From: Joan ventusproxy  
Sent: Monday, October 17, 2022 1:47 PM
To: 'Log4J Users List' 
Subject: RE: Issue after moving to log4j 2.19

Hello,

Investigating a little more ...

If I set the variable 
-Dlog4j.configurationFile=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml on 
the tomcat startup script, it works.

But setting this on my application, as we always did, it does not work any more:
System.setProperty("log4j.configurationFile", 
"/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");

The point is this is a simplified example, building this path is much more 
complicated and it must be done at application level, not tomcat level.

By the way, our web.xml contains this:

  
isLog4jContextSelectorNamed
true
  

  
log4jContextName
ventusproxy
  

Thanks,

Joan.


-Original Message-
From: Joan ventusproxy  
Sent: Sunday, October 16, 2022 9:03 PM
To: 'Log4J Users List' 
Subject: RE: Issue after moving to log4j 2.19

Is not this? (second gist):

DEBUG StatusLogger Watching configuration 
'/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml' for lastModified Sat Oct 15 
21:55:38 UTC 2022 (1665870938000) DEBUG StatusLogger Apache Log4j Core 2.19.0 
initializing configuration 
XmlConfiguration[location=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml]

Joan.

-Original Message-
From: Ralph Goers 
Sent: Sunday, October 16, 2022 2:44 AM
To: Log4J Users List 
Subject: Re: Issue after moving to log4j 2.19

In both of those log files Log4j is not seeing any value as being set of 
log4j.configurationFile. It is ending up using the default configuration.

Ralph

> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>  wrote:
> 
> Hi Piotr,
> 
> Thanks for your quick response.
> 
> Below two gists with the traces for both cases:
> 
> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c108
> 17900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt
> 
> In this case logs are not created.
> 
> 
> 2. Using "this.systemLog = 
> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a
> 196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt
> 
> In this case logs are created and content is logged into them correctly, but 
> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
> 
> 
> The " log4j.configurationFile " variable is set in this way:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> And tomcat starts with:
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLogger
> ContextSelector
> 
> 
> The point is that for years we have been running this without issues using 
> point 1, without getting the context from the LogManager.
> 
> One more clue. As I said, this is not working fine on our new installation 
> with Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same 
> code running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle jdk 
> 11 works perfectly, logs are created and the hazelcast logging is sent to the 
> SYSTEM_LOG.
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Piotr P. Karwasz 
> Sent: Friday, October 14, 2022 5:23 PM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> Hi Joan,
> 
>> After making a lot of tests trying to get this working again, we had to 
>> change the line below:
>> 
>> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>> 
>> 
>> 
>> By this:
>> 
>> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");
> 
> This looks like a `LoggerContextSelector` problem:
> https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSele
> ctor
> 
> `LogManager.getContext()` should not be used, because it gives you the wrong 
> logger context most of the time.
> The automatic configuration uses `LogManager.getContext(false)`

RE: Issue after moving to log4j 2.19

2022-10-17 Thread Joan ventusproxy
Hello,

Investigating a little more ...

If I set the variable 
-Dlog4j.configurationFile=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml on 
the tomcat startup script, it works.

But setting this on my application, as we always did, it does not work any more:
System.setProperty("log4j.configurationFile", 
"/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");

The point is this is a simplified example, building this path is much more 
complicated and it must be done at application level, not tomcat level.

By the way, our web.xml contains this:

  
isLog4jContextSelectorNamed
true
  

  
log4jContextName
ventusproxy
  

Thanks,

Joan.


-Original Message-
From: Joan ventusproxy  
Sent: Sunday, October 16, 2022 9:03 PM
To: 'Log4J Users List' 
Subject: RE: Issue after moving to log4j 2.19

Is not this? (second gist):

DEBUG StatusLogger Watching configuration 
'/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml' for lastModified Sat Oct 15 
21:55:38 UTC 2022 (1665870938000) DEBUG StatusLogger Apache Log4j Core 2.19.0 
initializing configuration 
XmlConfiguration[location=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml]

Joan.

-Original Message-
From: Ralph Goers 
Sent: Sunday, October 16, 2022 2:44 AM
To: Log4J Users List 
Subject: Re: Issue after moving to log4j 2.19

In both of those log files Log4j is not seeing any value as being set of 
log4j.configurationFile. It is ending up using the default configuration.

Ralph

> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>  wrote:
> 
> Hi Piotr,
> 
> Thanks for your quick response.
> 
> Below two gists with the traces for both cases:
> 
> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c108
> 17900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt
> 
> In this case logs are not created.
> 
> 
> 2. Using "this.systemLog = 
> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a
> 196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt
> 
> In this case logs are created and content is logged into them correctly, but 
> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
> 
> 
> The " log4j.configurationFile " variable is set in this way:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> And tomcat starts with:
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLogger
> ContextSelector
> 
> 
> The point is that for years we have been running this without issues using 
> point 1, without getting the context from the LogManager.
> 
> One more clue. As I said, this is not working fine on our new installation 
> with Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same 
> code running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle jdk 
> 11 works perfectly, logs are created and the hazelcast logging is sent to the 
> SYSTEM_LOG.
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Piotr P. Karwasz 
> Sent: Friday, October 14, 2022 5:23 PM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> Hi Joan,
> 
>> After making a lot of tests trying to get this working again, we had to 
>> change the line below:
>> 
>> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>> 
>> 
>> 
>> By this:
>> 
>> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");
> 
> This looks like a `LoggerContextSelector` problem:
> https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSele
> ctor
> 
> `LogManager.getContext()` should not be used, because it gives you the wrong 
> logger context most of the time.
> The automatic configuration uses `LogManager.getContext(false)` to retrieve 
> the right logger context.
> 
> Can you run your application with `-Dlog4j2.debug=true` and share the output?
> 
> Piotr
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 


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




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



RE: Issue after moving to log4j 2.19

2022-10-16 Thread Joan ventusproxy
Is not this? (second gist):

DEBUG StatusLogger Watching configuration 
'/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml' for lastModified Sat Oct 15 
21:55:38 UTC 2022 (1665870938000)
DEBUG StatusLogger Apache Log4j Core 2.19.0 initializing configuration 
XmlConfiguration[location=/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml]

Joan.

-Original Message-
From: Ralph Goers  
Sent: Sunday, October 16, 2022 2:44 AM
To: Log4J Users List 
Subject: Re: Issue after moving to log4j 2.19

In both of those log files Log4j is not seeing any value as being set of 
log4j.configurationFile. It is ending up using the default configuration.

Ralph

> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>  wrote:
> 
> Hi Piotr,
> 
> Thanks for your quick response.
> 
> Below two gists with the traces for both cases:
> 
> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c10817900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt
> 
> In this case logs are not created.
> 
> 
> 2. Using "this.systemLog = 
> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt
> 
> In this case logs are created and content is logged into them correctly, but 
> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
> 
> 
> The " log4j.configurationFile " variable is set in this way:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> And tomcat starts with:
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
> 
> 
> The point is that for years we have been running this without issues using 
> point 1, without getting the context from the LogManager.
> 
> One more clue. As I said, this is not working fine on our new installation 
> with Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same 
> code running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle jdk 
> 11 works perfectly, logs are created and the hazelcast logging is sent to the 
> SYSTEM_LOG.
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Piotr P. Karwasz  
> Sent: Friday, October 14, 2022 5:23 PM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> Hi Joan,
> 
>> After making a lot of tests trying to get this working again, we had to 
>> change the line below:
>> 
>> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>> 
>> 
>> 
>> By this:
>> 
>> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");
> 
> This looks like a `LoggerContextSelector` problem:
> https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector
> 
> `LogManager.getContext()` should not be used, because it gives you the wrong 
> logger context most of the time.
> The automatic configuration uses `LogManager.getContext(false)` to retrieve 
> the right logger context.
> 
> Can you run your application with `-Dlog4j2.debug=true` and share the output?
> 
> Piotr
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 


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




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



Re: Issue after moving to log4j 2.19

2022-10-16 Thread Piotr P. Karwasz
Hi Joan,

On Sun, 16 Oct 2022 at 00:45, Joan ventusproxy
 wrote:
> The " log4j.configurationFile " variable is set in this way:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");

For some unknown reason this is executed too late (after Log4j2
configuration). In the second file you posted you can see that Log4j2
is initialized twice: the first time the logger context associated
with your web app's classloader  picks up the default configuration,
because no `log4j2.configurationFile` setting is visible. Then
`log4j-web` configures what seems to be a second logger context with
your configuration (but `log4j-web` uses the `ServletContext` init
params to retrieve the configuration).

To find which component calls Log4j2 before `log4j-web` you can use
`-Dlog4j2.loggerContextStacktraceOnStart=true`. The web fragment
`log4j` contained in `log4j-web` requests to be executed before all
others, but you can change it with `` in your
`web.xml`.

> And tomcat starts with:
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

This setting basically breaks `log4j-web` ("WARN StatusLogger
Potential problem: Selector is not an instance of
NamedContextSelector."). Look into your web application descriptor and
remove the `isLog4jContextSelectorNamed` parameter. You can also use
the `BasicAsyncLoggerContextSelector` which always selects a thread
bound logger context (`log4j-web` manages the thread binding).

Piotr

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



Re: Issue after moving to log4j 2.19

2022-10-15 Thread Ralph Goers
In both of those log files Log4j is not seeing any value as being set of 
log4j.configurationFile. It is ending up using the default configuration.

Ralph

> On Oct 15, 2022, at 3:45 PM, Joan ventusproxy 
>  wrote:
> 
> Hi Piotr,
> 
> Thanks for your quick response.
> 
> Below two gists with the traces for both cases:
> 
> 1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c10817900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt
> 
> In this case logs are not created.
> 
> 
> 2. Using "this.systemLog = 
> LogManager.getContext().getLogger("LOGGER_SYSTEM");":
> https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt
> 
> In this case logs are created and content is logged into them correctly, but 
> the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 
> 
> 
> The " log4j.configurationFile " variable is set in this way:
> System.setProperty("log4j.configurationFile", 
> "/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");
> 
> And tomcat starts with:
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
> 
> 
> The point is that for years we have been running this without issues using 
> point 1, without getting the context from the LogManager.
> 
> One more clue. As I said, this is not working fine on our new installation 
> with Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same 
> code running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle jdk 
> 11 works perfectly, logs are created and the hazelcast logging is sent to the 
> SYSTEM_LOG.
> 
> 
> Thanks,
> 
> Joan.
> 
> -Original Message-
> From: Piotr P. Karwasz  
> Sent: Friday, October 14, 2022 5:23 PM
> To: Log4J Users List 
> Subject: Re: Issue after moving to log4j 2.19
> 
> Hi Joan,
> 
>> After making a lot of tests trying to get this working again, we had to 
>> change the line below:
>> 
>> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>> 
>> 
>> 
>> By this:
>> 
>> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");
> 
> This looks like a `LoggerContextSelector` problem:
> https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector
> 
> `LogManager.getContext()` should not be used, because it gives you the wrong 
> logger context most of the time.
> The automatic configuration uses `LogManager.getContext(false)` to retrieve 
> the right logger context.
> 
> Can you run your application with `-Dlog4j2.debug=true` and share the output?
> 
> Piotr
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 


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



RE: Issue after moving to log4j 2.19

2022-10-15 Thread Joan ventusproxy
Hi Piotr,

Thanks for your quick response.

Below two gists with the traces for both cases:

1. Using "this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");":
https://gist.githubusercontent.com/joanbalaguero/a59fb664774c44535c10817900a80ed5/raw/8bb6b6a963a607f0d99105248ce32a28ad39590a/gistfile1.txt

In this case logs are not created.


2. Using "this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");":
https://gist.githubusercontent.com/joanbalaguero/acd0a4edaf856ad34c44a196caef7bdc/raw/474febc0397b97a9b941dbd86b830149ac94ad07/gistfile1.txt

In this case logs are created and content is logged into them correctly, but 
the hazelcast log (from "com.hazelcast") is not sent to the SYSTEM_LOG. 


The " log4j.configurationFile " variable is set in this way:
System.setProperty("log4j.configurationFile", 
"/opt/ventusproxy/app/proxy/ROOT/WEB-INF/log4j.xml");

And tomcat starts with:
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector


The point is that for years we have been running this without issues using 
point 1, without getting the context from the LogManager.

One more clue. As I said, this is not working fine on our new installation with 
Centos9 Stream, Apache Tomcat 8.5.83 and Zing JVM 11. Exactly the same code 
running locally on a windows 10 with Apache Tomcat 8.5.39 and Oracle jdk 11 
works perfectly, logs are created and the hazelcast logging is sent to the 
SYSTEM_LOG.


Thanks,

Joan.

-Original Message-
From: Piotr P. Karwasz  
Sent: Friday, October 14, 2022 5:23 PM
To: Log4J Users List 
Subject: Re: Issue after moving to log4j 2.19

Hi Joan,

> After making a lot of tests trying to get this working again, we had to 
> change the line below:
>
> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>
>   
>
> By this:
>
> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");

This looks like a `LoggerContextSelector` problem:
https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector

`LogManager.getContext()` should not be used, because it gives you the wrong 
logger context most of the time.
 The automatic configuration uses `LogManager.getContext(false)` to retrieve 
the right logger context.

Can you run your application with `-Dlog4j2.debug=true` and share the output?

Piotr

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




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



Re: Issue after moving to log4j 2.19

2022-10-14 Thread Piotr P. Karwasz
Hi Joan,

> After making a lot of tests trying to get this working again, we had to 
> change the line below:
>
> this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");
>
>  �
>
> By this:
>
> this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");

This looks like a `LoggerContextSelector` problem:
https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector

`LogManager.getContext()` should not be used, because it gives you the
wrong logger context most of the time.
 The automatic configuration uses `LogManager.getContext(false)` to
retrieve the right logger context.

Can you run your application with `-Dlog4j2.debug=true` and share the output?

Piotr

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



Issue after moving to log4j 2.19

2022-10-12 Thread Joan ventusproxy
Hello,

 �

We have moved to log4j 2.19.0 from log4j 2.17.2. Our environment is Centos9 
stream with tomcat 8.5.83 and jdk11. After doing that, logging has stopped 
working (the code related to log4j2 has not been changed for years)

 �

All our loggers are asynchronous by adding:

-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

 �

The piece of log4j.xml:

 �



  



 %d{-MM-dd HH:mm:ss}\t%m%n













 �



   

   

 

   

 �

  

 





 �

Adding this before log creation:

System.setProperty("log4j2.debug", "true"); 

 �

We only got this when we printed the variable that should contain the system 
logger:

LOGGER_SYSTEM:ERROR in AsyncContext@587d32cc

 �

After making a lot of tests trying to get this working again, we had to change 
the line below:

this.systemLog = LogManager.getLogger("LOGGER_SYSTEM");

 �

By this:

this.systemLog = LogManager.getContext().getLogger("LOGGER_SYSTEM");

 �

And now it is almost working again, because the hazelcast log is not sent to 
the system logger yet. So our questions are:

 �

1.  Why must we get the logger from the context now? What has changed?
2.  What should we do to get the hazelcast logging working again, so send 
it to the system logger correctly.

 �

 �

Thanks,

 �

Joan.