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

Remko Popma resolved LOG4J2-638.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0-rc2
         Assignee: Remko Popma

This has been solved with the solution for LOG4J2-539.
ConfigurationSource is now a public class and can be obtained from 
LoggerContext.getConfiguration().getConfigurationSource().

This is now used in the MBean.

> Log4j2 JMX: getConfigText in LoggerContext is not working as documented
> -----------------------------------------------------------------------
>
>                 Key: LOG4J2-638
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-638
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: Mansoor Sajjad
>            Assignee: Remko Popma
>             Fix For: 2.0-rc2
>
>
> I am trying to configure log4j2 to access the loggers via JMX and change 
> their log levels.
> There are two operations that are available via LoggerContext in JConsole.
> 1. getConfigText
> 2. setConfigText
> The problem is with the first one. According to the documentation:
> getConfigText returns the configuration text, which may be
> 1. The contents of the configuration file.
> 2. The text that was last set with a call to setConfigText.
> The problem is that getConfigText works fine with second statement but its 
> not working with the first one. Which means if you try to get the 
> configuration text without first setting it with the setConfigText, you will 
> see the exception instead. The following one:
> {code}
> java.io.FileNotFoundException: 
> /usr/local/Cellar/tomcat/7.0.47/libexec/bin/Erex (No such file or directory)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:146)
> at java.io.FileInputStream.<init>(FileInputStream.java:101)
> at 
> sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
> at 
> sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
> at java.net.URL.openStream(URL.java:1037)
> at 
> org.apache.logging.log4j.core.jmx.LoggerContextAdmin.readContents(LoggerContextAdmin.java:203)
> at 
> org.apache.logging.log4j.core.jmx.LoggerContextAdmin.getConfigText(LoggerContextAdmin.java:161)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
> at sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
> 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.invoke(PerInterface.java:138)
> at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
> at 
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
> at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
> at 
> javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
> at 
> javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
> at 
> javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
> at 
> javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
> at 
> javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
> at sun.reflect.GeneratedMethodAccessor171.invoke(Unknown Source)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
> at sun.rmi.transport.Transport$1.run(Transport.java:177)
> at sun.rmi.transport.Transport$1.run(Transport.java:174)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
> at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
> at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:744)
> {code}
> I have set the configuration file path as a part of VM parameters like that:
> -Dlog4j.configurationFile=file:/Users/mansoor.sajjad/ErexLogs/exchange/conf/log4j2.xml
> But the exception logs showing that its trying to get the path from within 
> tomcat /usr/local/Cellar/tomcat/7.0.47/libexec/bin/Erex
> *My findings:*
> Debugging through the code I have found the configLocation inside the 
> LoggerContext is always null. Due to which the LoggerContextAdmin creates the 
> path using the ConfigName in the current path. ConfigName in my case is Erex 
> that and the current path is obviously the tomcat.
> So i get the path "/usr/local/Cellar/tomcat/7.0.47/libexec/bin/Erex", which 
> is wrong.
> Why the configLocation inside the LogerContext is always null?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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

Reply via email to