logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "billokara@gmail.com"<billok...@gmail.com>
Subject Issue with log4jConfiguration setting
Date Fri, 29 Sep 2017 21:55:44 GMT
Hi,

With log4j2 v 2.9.1 (same issue in previous version 2.6), by putting the log4j2.xml file in
WEB-INF/classes, log4j will eventually locate that config file as 'file:/'
====
ConfigLocationUri: file:/opt/tomcat/webapps/log4jTest/WEB-INF/classes/log4j2.xml
====
and the config file monitoring WILL WORK properly.

But when try to specify the config file by adding this to web.xml:
====
  <display-name>Log4j Test</display-name>
  <context-param>
    <description>log4j2 configuration file</description>
    <param-name>log4jConfiguration</param-name>
    <param-value>/WEB-INF/classes/log4j2.xml</param-value>
  </context-param>
====
it will be retrieved as (view in jmx):
====
ConfigLocationUri: jndi:/localhost/log4jTest/WEB-INF/classes/log4j2.xml
====

The problem with 'jndi:/' is that the config file seems NO LONGER being watched, and thus
the file monitor/reload DID NOT work.

Question: 
- is this a bug or how to make the file set via log4jConfiguration (using path relative to
web context, like the /WEB-INF/...) being monitored? 

In addition to that,  in the jndi:/ case, in jmx, the following Exception shown in the ConfigText
field

====
java.lang.IllegalStateException: Illegal class loader binding 	
at org.apache.naming.resources.DirContextURLStreamHandler.get(DirContextURLStreamHandler.java:228)
	
at org.apache.naming.resources.DirContextURLStreamHandler.openConnection(DirContextURLStreamHandler.java:90)
	
at java.net.URL.openConnection(URL.java:979) 	at java.net.URL.openStream(URL.java:1045) 	
at org.apache.logging.log4j.core.config.ConfigurationSource.resetInputStream(ConfigurationSource.java:202)
	
at org.apache.logging.log4j.core.jmx.LoggerContextAdmin.getConfigText(LoggerContextAdmin.java:158)
	
at org.apache.logging.log4j.core.jmx.LoggerContextAdmin.getConfigText(LoggerContextAdmin.java:151)
	
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 	
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 	
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 

at java.lang.reflect.Method.invoke(Method.java:498) 	
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) 	
at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) 	
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 

at java.lang.reflect.Method.invoke(Method.java:498) 	
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) 	
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
	
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
	
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237) 	
at com.sun.jmx.mbeanserver.PerInterface.getAttribute(PerInterface.java:83) 	
at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(MBeanSupport.java:206) 	
at com.sun.jmx.mbeanserver.MBeanSupport.getAttributes(MBeanSupport.java:213) 	
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttributes(DefaultMBeanServerInterceptor.java:709)
	
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttributes(JmxMBeanServer.java:705) 	
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1449)
	
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) 	
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
	
at javax.management.remote.rmi.RMIConnectionImpl.getAttributes(RMIConnectionImpl.java:675)
	
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source) 	
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 

at java.lang.reflect.Method.invoke(Method.java:498) 	
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) 	
at sun.rmi.transport.Transport$1.run(Transport.java:200) 	
at sun.rmi.transport.Transport$1.run(Transport.java:197) 	
at java.security.AccessController.doPrivileged(Native Method) 	
at sun.rmi.transport.Transport.serviceCall(Transport.java:196) 	
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) 	
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) 	
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	
at java.security.AccessController.doPrivileged(Native Method) 	
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) 	
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 	
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 	
at java.lang.Thread.run(Thread.java:748) 
====


Thanks!
Bill

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


Mime
View raw message