[jira] [Commented] (LOG4J2-3341) Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command line to set level and appenders at once

2022-03-01 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499826#comment-17499826
 ] 

Ralph Goers commented on LOG4J2-3341:
-

Initially all plugins used factory methods. Over time that became unwieldy as 
it led to a bunch of deprecated factory methods as you see here. Instead, any 
time a factory method needs to be changed we add a Builder instead as new 
methods can be added to builders without consequences. That is what happened 
here. 

> Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command 
> line to set level and appenders at once
> -
>
> Key: LOG4J2-3341
> URL: https://issues.apache.org/jira/browse/LOG4J2-3341
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Configuration
>Reporter: Duo Zhang
>Assignee: Matt Sicker
>Priority: Major
> Fix For: 2.17.2
>
> Attachments: log4j2.err, log4j2.properties
>
>
> Please see the discussion thread on the dev list.
> https://lists.apache.org/thread/gvfb3jkg6t11cyds4jmpo7lrswmx28w3
> The current direction is to introduce a new plugin to split the command line 
> argument.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Piotr P. Karwasz (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499774#comment-17499774
 ] 

Piotr P. Karwasz commented on LOG4J2-3420:
--

Due to the removal of {{sun.reflect.Reflection}} in Java 9, Log4j provides two 
versions of the {{StackLocatorUtil}} class: a standard version for Java 8 or 
less and one for Java 9 or later.

It seems looks like NetBeans is picking the Java 8 version, although your JVM 
is more recent. 

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Assignee: Ralph Goers
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Resolved] (LOG4J2-3422) Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property using log4j-spring-boot

2022-03-01 Thread Ralph Goers (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ralph Goers resolved LOG4J2-3422.
-
Resolution: Duplicate

Resolving as a duplicate (which already has a PR).

> Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property 
> using log4j-spring-boot
> -
>
> Key: LOG4J2-3422
> URL: https://issues.apache.org/jira/browse/LOG4J2-3422
> Project: Log4j 2
>  Issue Type: Improvement
>Affects Versions: 2.17.1
> Environment: spring-boot-2.6.4, log4j2-2.17.1
>Reporter: member sound
>Priority: Major
>
> Follow-Up issue from discussion in 
> [https://github.com/spring-projects/spring-boot/issues/30017]
> Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
> applications.
> Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
> dependency, then *all* applications running on the same tomcat are forced to 
> add this dependency.
> This seems to be because:
> {code:java}
> org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
> {code}
> [https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]
> [https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]
> This is even worse of other applications would normally rely on the 
> spring-default logback logging framework. They are then forced to switch to 
> Log4j2.
>  
> I think a dependency should not have an impact on other projects. That 
> contradicts every developer theorem.
> Maybe this is even a bug, though I flagged it as a Feature for the moment.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ernie Rael (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499740#comment-17499740
 ] 

Ernie Rael commented on LOG4J2-3420:


[~ppkarwasz] It does work with Java 8. Thanks for asking.

I don't understand the implications of the multi-release jar question. Or how 
to find the answer.

I'll ask the NB dev mailing list.

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Assignee: Ralph Goers
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3341) Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command line to set level and appenders at once

2022-03-01 Thread Jeremy Norris (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499718#comment-17499718
 ] 

Jeremy Norris commented on LOG4J2-3341:
---

Additionally, the other 
[LoggerConfig.createLogger()|https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/LoggerConfig.html#createLogger-java.lang.String-org.apache.logging.log4j.Level-java.lang.String-java.lang.String-org.apache.logging.log4j.core.config.AppenderRef:A-org.apache.logging.log4j.core.config.Property:A-org.apache.logging.log4j.core.config.Configuration-org.apache.logging.log4j.core.Filter-]
 method includes a deprecation that points you to use this newly deprecated 
method, which is confusing...

> Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command 
> line to set level and appenders at once
> -
>
> Key: LOG4J2-3341
> URL: https://issues.apache.org/jira/browse/LOG4J2-3341
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Configuration
>Reporter: Duo Zhang
>Assignee: Matt Sicker
>Priority: Major
> Fix For: 2.17.2
>
> Attachments: log4j2.err, log4j2.properties
>
>
> Please see the discussion thread on the dev list.
> https://lists.apache.org/thread/gvfb3jkg6t11cyds4jmpo7lrswmx28w3
> The current direction is to introduce a new plugin to split the command line 
> argument.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3341) Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command line to set level and appenders at once

2022-03-01 Thread Jeremy Norris (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499714#comment-17499714
 ] 

Jeremy Norris commented on LOG4J2-3341:
---

Why was LoggerConfig.createLogger() method deprecated in 
5a459dda1e731dfa93198db63493c1cb1cd1e941?
And what is the suggested migration path for users?
There is no documentation as to why it's deprecated and what users should 
migrate to according to the published 
[Javadocs|https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/LoggerConfig.html#createLogger-boolean-org.apache.logging.log4j.Level-java.lang.String-java.lang.String-org.apache.logging.log4j.core.config.AppenderRef:A-org.apache.logging.log4j.core.config.Property:A-org.apache.logging.log4j.core.config.Configuration-org.apache.logging.log4j.core.Filter-]
 or changelog that I can see.

> Support passing something like '-Dlog4j.rootLogger=INFO,Console' from command 
> line to set level and appenders at once
> -
>
> Key: LOG4J2-3341
> URL: https://issues.apache.org/jira/browse/LOG4J2-3341
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Configuration
>Reporter: Duo Zhang
>Assignee: Matt Sicker
>Priority: Major
> Fix For: 2.17.2
>
> Attachments: log4j2.err, log4j2.properties
>
>
> Please see the discussion thread on the dev list.
> https://lists.apache.org/thread/gvfb3jkg6t11cyds4jmpo7lrswmx28w3
> The current direction is to introduce a new plugin to split the command line 
> argument.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (LOG4J2-3422) Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property using log4j-spring-boot

2022-03-01 Thread member sound (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

member sound updated LOG4J2-3422:
-
Description: 
Follow-Up issue from discussion in 
[https://github.com/spring-projects/spring-boot/issues/30017]

Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
applications.

Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
dependency, then *all* applications running on the same tomcat are forced to 
add this dependency.

This seems to be because:
{code:java}
org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
{code}
[https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]

[https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]

This is even worse of other applications would normally rely on the 
spring-default logback logging framework. They are then forced to switch to 
Log4j2.

 

I think a dependency should not have an impact on other projects. That 
contradicts every developer theorem.

Maybe this is even a bug, though I flagged it as a Feature for the moment.

  was:
Follow-Up issue from discussion in 
[https://github.com/spring-projects/spring-boot/issues/30017]

Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
applications.

Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
dependency, then *all* applications running on the same tomcat are forced to 
add this dependency.

This seems to be because:
{code:java}
org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
{code}
[https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]

[https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]

This is even worse of other applications would normally rely on the 
spring-default logback logging framework. They are then forced to switch to 
Log4j2.

 

I think a dependency should not have an impact on other projects. That 
contradicts every developer theorem.


> Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property 
> using log4j-spring-boot
> -
>
> Key: LOG4J2-3422
> URL: https://issues.apache.org/jira/browse/LOG4J2-3422
> Project: Log4j 2
>  Issue Type: Improvement
>Affects Versions: 2.17.1
> Environment: spring-boot-2.6.4, log4j2-2.17.1
>Reporter: member sound
>Priority: Major
>
> Follow-Up issue from discussion in 
> [https://github.com/spring-projects/spring-boot/issues/30017]
> Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
> applications.
> Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
> dependency, then *all* applications running on the same tomcat are forced to 
> add this dependency.
> This seems to be because:
> {code:java}
> org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
> {code}
> [https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]
> [https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]
> This is even worse of other applications would normally rely on the 
> spring-default logback logging framework. They are then forced to switch to 
> Log4j2.
>  
> I think a dependency should not have an impact on other projects. That 
> contradicts every developer theorem.
> Maybe this is even a bug, though I flagged it as a Feature for the moment.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (LOG4J2-3422) Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property using log4j-spring-boot

2022-03-01 Thread member sound (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

member sound updated LOG4J2-3422:
-
Description: 
Follow-Up issue from discussion in 
[https://github.com/spring-projects/spring-boot/issues/30017]

Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
applications.

Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
dependency, then *all* applications running on the same tomcat are forced to 
add this dependency.

This seems to be because:
{code:java}
org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
{code}
[https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]

[https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]

This is even worse of other applications would normally rely on the 
spring-default logback logging framework. They are then forced to switch to 
Log4j2.

 

I think a dependency should not have an impact on other projects. That 
contradicts every developer theorem.

  was:
Follow-Up issue from discussion in 
https://github.com/spring-projects/spring-boot/issues/30017

Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
applications.

Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
dependency, then *all* applications running on the same tomcat are forced to 
add this dependency.

This seems to be because:
{code}
org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
{code}

https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17

https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java

This is even worse of other applications would normally rely on the 
spring-default logback logging framework. They are then forced to switch to 
Log4j2.


> Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property 
> using log4j-spring-boot
> -
>
> Key: LOG4J2-3422
> URL: https://issues.apache.org/jira/browse/LOG4J2-3422
> Project: Log4j 2
>  Issue Type: Improvement
>Affects Versions: 2.17.1
> Environment: spring-boot-2.6.4, log4j2-2.17.1
>Reporter: member sound
>Priority: Major
>
> Follow-Up issue from discussion in 
> [https://github.com/spring-projects/spring-boot/issues/30017]
> Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
> applications.
> Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
> dependency, then *all* applications running on the same tomcat are forced to 
> add this dependency.
> This seems to be because:
> {code:java}
> org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
> {code}
> [https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17]
> [https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java]
> This is even worse of other applications would normally rely on the 
> spring-default logback logging framework. They are then forced to switch to 
> Log4j2.
>  
> I think a dependency should not have an impact on other projects. That 
> contradicts every developer theorem.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Created] (LOG4J2-3422) Prevent setting Log4j2CloudConfigLoggingSystem as tomcat-wide system property using log4j-spring-boot

2022-03-01 Thread member sound (Jira)
member sound created LOG4J2-3422:


 Summary: Prevent setting Log4j2CloudConfigLoggingSystem as 
tomcat-wide system property using log4j-spring-boot
 Key: LOG4J2-3422
 URL: https://issues.apache.org/jira/browse/LOG4J2-3422
 Project: Log4j 2
  Issue Type: Improvement
Affects Versions: 2.17.1
 Environment: spring-boot-2.6.4, log4j2-2.17.1
Reporter: member sound


Follow-Up issue from discussion in 
https://github.com/spring-projects/spring-boot/issues/30017

Setting: Tomcat 9 Standalone Server with *multiple* independent spring-boot 
applications.

Problem: as soon as one of those applications adds {{log4j-spring-boot}} 
dependency, then *all* applications running on the same tomcat are forced to 
add this dependency.

This seems to be because:
{code}
org.springframework.boot.logging.LoggingSystem=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem
{code}

https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-spring-boot/src/main/resources/log4j2.system.properties#L17

https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java

This is even worse of other applications would normally rely on the 
spring-default logback logging framework. They are then forced to switch to 
Log4j2.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Piotr P. Karwasz (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499703#comment-17499703
 ] 

Piotr P. Karwasz commented on LOG4J2-3420:
--

I am wondering whether NetBeans supports multi-release jars.

[~errael] , have you tried with Java 8?

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Assignee: Ralph Goers
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3419) Unable to create custom logging level using log4j 2 Bridge API

2022-03-01 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499675#comment-17499675
 ] 

Ralph Goers commented on LOG4J2-3419:
-

You could modify your constructor to do 

 
{code:java}
 private Level(int paramInt1, String paramString, int paramInt2)
  {
     super(paramInt1, paramString, paramInt2);
 org.apache.logging.log4j.Level.forName(paaramString), paramInt1);
  } {code}
I should point out though that in Log4j 1 a value of 13000 would be between 
DEBUG and INFO. In Log4j 2 that value would be more limiting than TRACE. To 
solve this you would need to create an adjustLevel method that calculates the 
Log4j 2 level based on the Log4j 1 level. So you might equate 13000 to DEBUG + 
3000. In Log4j 2 you would then do StandardLevel.DEBUG - (3000 / 100) which 
would result in a value or 470.

 

> Unable to create custom logging level using log4j 2 Bridge API
> --
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Log4j 1.2 bridge
>Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
>Reporter: Ragini Gawande
>Priority: Blocker
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);* 
>  
> Using FINE logging level is considered to be DEBUG level by default while 
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>  
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT: 
> Level.FINE log 
>  
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT: 
> Level.FINE log 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499668#comment-17499668
 ] 

Ralph Goers commented on LOG4J2-3420:
-

I am looking at all the getLogger methods and they do not look correct to me at 
all. They should be attempting to get the ClassLoader of the caller but they 
don't seem to be doing that at all.

I will need to either look at existing unit tests or create new ones.

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Assigned] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ralph Goers (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ralph Goers reassigned LOG4J2-3420:
---

Assignee: Ralph Goers

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Assignee: Ralph Goers
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3419) Unable to create custom logging level using log4j 2 Bridge API

2022-03-01 Thread Ragini Gawande (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499653#comment-17499653
 ] 

Ragini Gawande commented on LOG4J2-3419:


This same code worked with log4j 1.2.x, we were able to see our custom level 
printed properly.

Is there any plan to fix this for log4j 2 bridge API?

Or is there any other way by which I can create the custom log level using 
log4j bridge API?

> Unable to create custom logging level using log4j 2 Bridge API
> --
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Log4j 1.2 bridge
>Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
>Reporter: Ragini Gawande
>Priority: Blocker
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);* 
>  
> Using FINE logging level is considered to be DEBUG level by default while 
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>  
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT: 
> Level.FINE log 
>  
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT: 
> Level.FINE log 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ralph Goers (Jira)


[ https://issues.apache.org/jira/browse/LOG4J2-3420 ]


Ralph Goers deleted comment on LOG4J2-3420:
-

was (Author: ralph.go...@dslextreme.com):
What happens if you do
{code:java}
public class MyTextField extends JTextField {
  final private static Logger logger = LogManager.getLogger(MyTextField.class);
  public MyTextField(){}
} {code}

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499648#comment-17499648
 ] 

Ralph Goers commented on LOG4J2-3420:
-

What happens if you do
{code:java}
public class MyTextField extends JTextField {
  final private static Logger logger = LogManager.getLogger(MyTextField.class);
  public MyTextField(){}
} {code}

> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> This exception similarly occurs with clazz.newInstance(), which is sometimes 
> used by the guiBuilder. It also occurs if the getLogger is in the constructor 
> rather than a static.
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3419) Unable to create custom logging level using log4j 2 Bridge API

2022-03-01 Thread Ralph Goers (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499645#comment-17499645
 ] 

Ralph Goers commented on LOG4J2-3419:
-

The log method in the 1.2 bridge first checks that the priority is not 
filtered. The is performed by:
{code:java}
isEnabledFor(org.apache.logging.log4j.Level.toLevel(level.toString())) {code}
For this to work the Level would need to be added as a custom level to Log4j 2. 
But neither the Level or Priority constructors do that. So this Level will 
always be treated by Log4j 2 as the default level.

> Unable to create custom logging level using log4j 2 Bridge API
> --
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Log4j 1.2 bridge
>Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
>Reporter: Ragini Gawande
>Priority: Blocker
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);* 
>  
> Using FINE logging level is considered to be DEBUG level by default while 
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>  
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT: 
> Level.FINE log 
>  
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT: 
> Level.FINE log 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3419) Unable to create custom logging level using log4j 2 Bridge API

2022-03-01 Thread Ragini Gawande (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499643#comment-17499643
 ] 

Ragini Gawande commented on LOG4J2-3419:


Hi [~ggregory] 

We have extended the org.apache.log4j.Level class as followed

*public class Level extends org.apache.log4j.Level*

and the constructor in my extended class Level is:

{color:#172b4d}  *private Level(int paramInt1, String paramString, int 
paramInt2)*{color}
{color:#172b4d}  *{*{color}
{color:#172b4d}    *super(paramInt1, paramString, paramInt2);*{color}
{color:#172b4d}  *}*{color}

We are then creating our custom logging level in my extended Level class as 
mentioned in the description 

_public static final int FINE_INT = 13000;_

_public static final Level FINE = new Level(FINE_INT, "FINE", 7);_ 

> Unable to create custom logging level using log4j 2 Bridge API
> --
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Log4j 1.2 bridge
>Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
>Reporter: Ragini Gawande
>Priority: Blocker
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);* 
>  
> Using FINE logging level is considered to be DEBUG level by default while 
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>  
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT: 
> Level.FINE log 
>  
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT: 
> Level.FINE log 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3419) Unable to create custom logging level using log4j 2 Bridge API

2022-03-01 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499619#comment-17499619
 ] 

Gary D. Gregory commented on LOG4J2-3419:
-

Hi [~ragini] 

Would you provide a PR on GitHub with a failing test?

The example in the description should not even compile since 
{{org.apache.log4j.Level.Level(int, String, int)}} is a protected constructor.

So there is some mismatch in my understanding of what the description expresses.

 

 

> Unable to create custom logging level using log4j 2 Bridge API
> --
>
> Key: LOG4J2-3419
> URL: https://issues.apache.org/jira/browse/LOG4J2-3419
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Log4j 1.2 bridge
>Affects Versions: 2.17.1
> Environment: Using log4j 2 bridge API: log4j-1.2-api-2.17.1.jar
>Reporter: Ragini Gawande
>Priority: Blocker
>
> Unable to create custom logging level using log4j 2 Bridge API
> Following did not create a custom logging level
> *public static final int FINE_INT = 13000;*
> *public static final Level FINE = new Level(FINE_INT, "FINE", 7);* 
>  
> Using FINE logging level is considered to be DEBUG level by default while 
> printing it
> *Adding log:*
> log.log({*}Level.FINE{*},"PRINT: Level.FINE log");
>  
> *Expected log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *FINE* - PRINT: 
> Level.FINE log 
>  
> *Actual log printed:*
> 2022-02-25 15:50:09,208 Main[6788] :main: example.com.Test *DEBUG* - PRINT: 
> Level.FINE log 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (LOG4J2-3421) Programmatic Configuration

2022-03-01 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-3421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499515#comment-17499515
 ] 

Gary D. Gregory commented on LOG4J2-3421:
-

[~sovikstepan] 

Thank you for this report.

Would you provide a PR on the github branch release-2.x?

> Programmatic Configuration
> --
>
> Key: LOG4J2-3421
> URL: https://issues.apache.org/jira/browse/LOG4J2-3421
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Configuration, Documentation
>Affects Versions: 2.17.1
>Reporter: Štěpán Sovík
>Priority: Major
>
> The documentation provided here: 
> [https://logging.apache.org/log4j/2.x/manual/customconfig.html] contains 
> plenty of 'code snippets' that are using deprecated API, non-compilable 
> issues ... and even when one fixes all, it still doesn't work.
> Documentation issues need to be fixed and documentation updated so it's 
> obvious how it should actually work.
> Just some examples:
>  
> {code:java}
> public Configuration getConfiguration(InputSource source) {return 
> new MyXMLConfiguration(source, configFile);} {code}
> Where the configFile comes from??
>  
>  
> {code:java}
> @Overrideprotected void doConfigure() {super.doConfigure();   
>  final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);  
>   final Configuration config = context.getConfiguration();final 
> Layout layout = PatternLayout.createDefaultLayout(config);final 
> Appender appender = FileAppender.createAppender("target/test.log", "false", 
> "false", "File", "true",  "false", "false", "4000", layout, null, 
> "false", null, config);appender.start();
> addAppender(appender);LoggerConfig loggerConfig = 
> LoggerConfig.createLogger("false", "info", "org.apache.logging.log4j",
>   "true", refs, null, config, null );
> loggerConfig.addAppender(appender, null, null);
> addLogger("org.apache.logging.log4j", loggerConfig);} {code}
> Where the refs come from??
>  
>  
> {code:java}
> final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
> final Configuration config = context.getConfiguration(); {code}
> Really? No one was doing some kind of review on this?? Code snippets were 
> done in plain text editors?
>  
> {code:java}
>         LoggerConfig loggerConfig = LoggerConfig.createLogger("false", 
> "info", "org.apache.logging.log4j",
>             "true", refs, null, config, null ); {code}
> Come on! This cannot be even compiled ... because "{_}The method 
> createLogger(String, Level, String, String, AppenderRef[], Property[], 
> Configuration, Filter) in the type LoggerConfig is not applicable for the 
> arguments (String, String, String, String, AppenderRef[], null, 
> Configuration, null){_}"
> I've never seen such a badly documented feature before.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Created] (LOG4J2-3421) Programmatic Configuration

2022-03-01 Thread Jira
Štěpán Sovík created LOG4J2-3421:


 Summary: Programmatic Configuration
 Key: LOG4J2-3421
 URL: https://issues.apache.org/jira/browse/LOG4J2-3421
 Project: Log4j 2
  Issue Type: Bug
  Components: Configuration, Documentation
Affects Versions: 2.17.1
Reporter: Štěpán Sovík


The documentation provided here: 
[https://logging.apache.org/log4j/2.x/manual/customconfig.html] contains plenty 
of 'code snippets' that are using deprecated API, non-compilable issues ... and 
even when one fixes all, it still doesn't work.

Documentation issues need to be fixed and documentation updated so it's obvious 
how it should actually work.

Just some examples:

 
{code:java}
public Configuration getConfiguration(InputSource source) {return 
new MyXMLConfiguration(source, configFile);} {code}
Where the configFile comes from??

 

 
{code:java}
@Overrideprotected void doConfigure() {super.doConfigure(); 
   final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);  
  final Configuration config = context.getConfiguration();final Layout 
layout = PatternLayout.createDefaultLayout(config);final Appender 
appender = FileAppender.createAppender("target/test.log", "false", "false", 
"File", "true",  "false", "false", "4000", layout, null, "false", 
null, config);appender.start();addAppender(appender);
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", "info", 
"org.apache.logging.log4j",  "true", refs, null, config, null );
loggerConfig.addAppender(appender, null, null);
addLogger("org.apache.logging.log4j", loggerConfig);} {code}
Where the refs come from??

 

 
{code:java}
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = context.getConfiguration(); {code}
Really? No one was doing some kind of review on this?? Code snippets were done 
in plain text editors?

 
{code:java}
        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", "info", 
"org.apache.logging.log4j",
            "true", refs, null, config, null ); {code}
Come on! This cannot be even compiled ... because "{_}The method 
createLogger(String, Level, String, String, AppenderRef[], Property[], 
Configuration, Filter) in the type LoggerConfig is not applicable for the 
arguments (String, String, String, String, AppenderRef[], null, Configuration, 
null){_}"

I've never seen such a badly documented feature before.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ernie Rael (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ernie Rael updated LOG4J2-3420:
---
Description: 
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
This exception similarly occurs with clazz.newInstance(), which is sometimes 
used by the guiBuilder. It also occurs if the getLogger is in the constructor 
rather than a static.

As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}

  was:
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
This exception similarly occurs with clazz.newInstance(), which is sometimes 
used by the guiBuilder.

As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}


> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropria

[jira] [Updated] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ernie Rael (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ernie Rael updated LOG4J2-3420:
---
Description: 
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
This exception similarly occurs with clazz.newInstance(), which is sometimes 
used by the guiBuilder.

As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}

  was:
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
This exception similarly occurs with clazz.newInstance(), which is sometimes 
used by the guiBuilder.

As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
Logger logger;
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}


> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogM

[jira] [Updated] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ernie Rael (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ernie Rael updated LOG4J2-3420:
---
Description: 
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
This exception similarly occurs with clazz.newInstance(), which is sometimes 
used by the guiBuilder.

As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
Logger logger;
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}

  was:
Exception arises when this class is used in the NetBeans guiBuilder.
{code:java}
public class MyTextField extends JTextField {
final private static Logger logger = LogManager.getLogger();
public MyTextField(){}
}
{code}
Get the following exception when the bean is selected to drop on the gui.
{noformat}
INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
class play.MyTextField from unknown source.
The class itself was found, but there was a problem initializing it, e.g. due 
to an exception in static initializer, or failure in loading an additional 
class needed by the component class. Check the attached exception.
java.lang.UnsupportedOperationException: No class provided, and an appropriate 
one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
at play.MyTextField.(MyTextField.java:35)
Caused: java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at 
org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
{noformat}
As a workaround, since I can compile the gui component, I'm invoking 
Stuff.getLogger()
{code:java}
public class Stuff {
static Logger getLogger() {
Logger logger;
try {
return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
} catch(UnsupportedOperationException ex) {}
return LogManager.getRootLogger();
}
}
{code}


> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.get

[jira] [Updated] (LOG4J2-3420) getlogger() UnsupportedOperationException when loaded by Class.forName()

2022-03-01 Thread Ernie Rael (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ernie Rael updated LOG4J2-3420:
---
Environment: 
Several versions of log4j 2.

Tried with several versions of jdk (the exception shown is jdk-17).

 

  was:
Several versions of log4j 2.

 

Tried with several versions of jdk (the exception shown is jdk-17).

 


> getlogger() UnsupportedOperationException when loaded by Class.forName()
> 
>
> Key: LOG4J2-3420
> URL: https://issues.apache.org/jira/browse/LOG4J2-3420
> Project: Log4j 2
>  Issue Type: Bug
>  Components: API
>Affects Versions: 2.17.2
> Environment: Several versions of log4j 2.
> Tried with several versions of jdk (the exception shown is jdk-17).
>  
>Reporter: Ernie Rael
>Priority: Major
>
> Exception arises when this class is used in the NetBeans guiBuilder.
> {code:java}
> public class MyTextField extends JTextField {
> final private static Logger logger = LogManager.getLogger();
> public MyTextField(){}
> }
> {code}
> Get the following exception when the bean is selected to drop on the gui.
> {noformat}
> INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component 
> class play.MyTextField from unknown source.
> The class itself was found, but there was a problem initializing it, e.g. due 
> to an exception in static initializer, or failure in loading an additional 
> class needed by the component class. Check the attached exception.
> java.lang.UnsupportedOperationException: No class provided, and an 
> appropriate one cannot be found.
> at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598)
> at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
> at play.MyTextField.(MyTextField.java:35)
> Caused: java.lang.ExceptionInInitializerError
> at java.base/java.lang.Class.forName0(Native Method)
> at java.base/java.lang.Class.forName(Class.java:467)
> at 
> org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89)
> {noformat}
> As a workaround, since I can compile the gui component, I'm invoking 
> Stuff.getLogger()
> {code:java}
> public class Stuff {
> static Logger getLogger() {
> Logger logger;
> try {
> return LogManager.getLogger(StackLocatorUtil.getCallerClass(2));
> } catch(UnsupportedOperationException ex) {}
> return LogManager.getRootLogger();
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)