You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by sherryhw <sh...@gmail.com> on 2017/12/14 17:52:47 UTC

What is the path for Log4j configuration?

Hi guys, 
I am using Log4j2 for Ignite logging, but I always have this error:
"* Failed to instantiate [org.apache.ignite.logger.log4j2.Log4J2Logger]:
Constructor threw exception; nested exception is class
org.apache.ignite.IgniteCheckedException: Log4j configuration path was not
found:config/log4j2.xml*"

This is my configuration.
*data-node-config.xml*
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="gridLogger">
            <bean class="org.apache.ignite.logger.log4j2.Log4J2Logger">
                <constructor-arg type="java.lang.String"
value="config/log4j2.xml"/>
            </bean>
        </property>
</bean>
And my log4j2.xml locates in the same folder as data-node-config.xml. Both
of them are in config folder.
File structure:
--src
  |--main
    |--java
      |--DataNodeStartUp.java
    |--resources
      |--config
         |--data-node-config.xml
         |--log4j2.xml
However, whenever I run DataNodeStartUp.java main method to call "Ignite
ignite = Ignition.start("config/data-node-config.xml");" to start my
data-node, it always has the error for cannot find the  Log4j configuration
path. 
If I use the absolute path it can work. So there is nothing wrong with my
other configurations. What is this relative path of log4j2.xml?

Thanks!
 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: What is the path for Log4j configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
I’ve looked at Ignite’s Log4j2Logger. It calls Log4j2’s Configurator when the class is constructed. The problem here is that if you are using Log4j 2 and are logging before Ignite initializes you do not want this behavior. Furthermore, it tries to programmatically create a ConsoleAppender, which is likely you don’t want or need.  I am thinking I will create an alternate Logger for Ignite that doesn’t do any of this and submit a PR for it. With that you will just configure Log4j according to the Log4j documentation and these problems will go away. I could add it to Log4j itself but it really doesn’t belong there.

Ralph

> On Dec 14, 2017, at 12:00 PM, Ralph Goers <ra...@dslextreme.com> wrote:
> 
> Did you add the status=“DEBUG”?  I suspect that log4j is being initialized before ignite starts and then Ignite is trying to reconfigure it. Previously you had no log4j2.xml so the initial configuration failed but Ignite’s probably worked. Once you moved the file the initial configuration worked but Ignite was unable to configure logging. Personally, I have my own version of Log4j2Logger that only routes ignites logging calls to Log4j and does none of the extra stuff. In that case you just configure Log4j “normally” and this problem doesn’t occur.  I’ll take a look at the Ignite code and try to determine why it is having these problems.
> 
> Ralph
> 
>> On Dec 14, 2017, at 11:27 AM, sherryhw <sh...@gmail.com> wrote:
>> 
>> I moved the log4j2.xml into the resources folder now.
>> --resources
>> |--config
>>     |--data-node-config.xml
>> |--log4j2.xml
>> 
>> Now when I start the data-node, the spring log file is fine at first, can
>> printout the debug mode of spring log, however, it still fails at Ignite.
>> "Exception in thread "main" class org.apache.ignite.IgniteException: Failed
>> to instantiate Spring XML application context
>> [springUrl=..../target/classes/config/data-node-config.xml, err=Error
>> creating bean with name
>> 'org.apache.ignite.configuration.IgniteConfiguration#0' defined in URL
>> [...target/classes/config/data-node-config.xml]: Cannot create inner bean
>> 'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' of type
>> [org.apache.ignite.logger.log4j2.Log4J2Logger] while setting bean property
>> 'gridLogger'; nested exception is
>> org.springframework.beans.factory.BeanCreationException: Error creating bean
>> with name 'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' defined in
>> URL [..../target/classes/config/data-node-config.xml]: Bean instantiation
>> via constructor failed; nested exception is
>> org.springframework.beans.BeanInstantiationException: Failed to instantiate
>> [org.apache.ignite.logger.log4j2.Log4J2Logger]: Constructor threw exception;
>> nested exception is class org.apache.ignite.IgniteCheckedException: Log4j
>> configuration path was not found: /log4j2.xml]
>> "
>> 
>> So the issue should be within the ignite trying to configure the log.
>> Do you have any ideas how to resolve it?
>> If I use absolute path, it could work correctly.
>> 
>> 
>> 
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>> 
> 
> 
> 



Re: What is the path for Log4j configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
Did you add the status=“DEBUG”?  I suspect that log4j is being initialized before ignite starts and then Ignite is trying to reconfigure it. Previously you had no log4j2.xml so the initial configuration failed but Ignite’s probably worked. Once you moved the file the initial configuration worked but Ignite was unable to configure logging. Personally, I have my own version of Log4j2Logger that only routes ignites logging calls to Log4j and does none of the extra stuff. In that case you just configure Log4j “normally” and this problem doesn’t occur.  I’ll take a look at the Ignite code and try to determine why it is having these problems.

Ralph

> On Dec 14, 2017, at 11:27 AM, sherryhw <sh...@gmail.com> wrote:
> 
> I moved the log4j2.xml into the resources folder now.
> --resources
>  |--config
>      |--data-node-config.xml
>  |--log4j2.xml
> 
> Now when I start the data-node, the spring log file is fine at first, can
> printout the debug mode of spring log, however, it still fails at Ignite.
> "Exception in thread "main" class org.apache.ignite.IgniteException: Failed
> to instantiate Spring XML application context
> [springUrl=..../target/classes/config/data-node-config.xml, err=Error
> creating bean with name
> 'org.apache.ignite.configuration.IgniteConfiguration#0' defined in URL
> [...target/classes/config/data-node-config.xml]: Cannot create inner bean
> 'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' of type
> [org.apache.ignite.logger.log4j2.Log4J2Logger] while setting bean property
> 'gridLogger'; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' defined in
> URL [..../target/classes/config/data-node-config.xml]: Bean instantiation
> via constructor failed; nested exception is
> org.springframework.beans.BeanInstantiationException: Failed to instantiate
> [org.apache.ignite.logger.log4j2.Log4J2Logger]: Constructor threw exception;
> nested exception is class org.apache.ignite.IgniteCheckedException: Log4j
> configuration path was not found: /log4j2.xml]
> "
> 
> So the issue should be within the ignite trying to configure the log.
> Do you have any ideas how to resolve it?
> If I use absolute path, it could work correctly.
> 
> 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
> 



Re: What is the path for Log4j configuration?

Posted by sherryhw <sh...@gmail.com>.
I moved the log4j2.xml into the resources folder now.
--resources
  |--config
      |--data-node-config.xml
  |--log4j2.xml

Now when I start the data-node, the spring log file is fine at first, can
printout the debug mode of spring log, however, it still fails at Ignite.
"Exception in thread "main" class org.apache.ignite.IgniteException: Failed
to instantiate Spring XML application context
[springUrl=..../target/classes/config/data-node-config.xml, err=Error
creating bean with name
'org.apache.ignite.configuration.IgniteConfiguration#0' defined in URL
[...target/classes/config/data-node-config.xml]: Cannot create inner bean
'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' of type
[org.apache.ignite.logger.log4j2.Log4J2Logger] while setting bean property
'gridLogger'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.ignite.logger.log4j2.Log4J2Logger#d2de489' defined in
URL [..../target/classes/config/data-node-config.xml]: Bean instantiation
via constructor failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.apache.ignite.logger.log4j2.Log4J2Logger]: Constructor threw exception;
nested exception is class org.apache.ignite.IgniteCheckedException: Log4j
configuration path was not found: /log4j2.xml]
"

So the issue should be within the ignite trying to configure the log.
Do you have any ideas how to resolve it?
If I use absolute path, it could work correctly.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: What is the path for Log4j configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
I should qualify that. I would have to look at Ignite’s version of the Log4j2Logger class (I don’t use that myself as it does some things I don’t care for). If it is properly calling the Log4j 2 Configurator with the path you provided then it should be working. However, there are scenarios where it may be initializing Log4j 2 properly but Log4j tried to configure itself first and didn’t find the file but then Ignite forced it to reconfigure with the new file. In that case you can ignore the error message.  You should add status=“DEBUG” to the configuration element in your log4j2.xml to see if the file is ever being configured.

Ralph

> On Dec 14, 2017, at 11:09 AM, Ralph Goers <ra...@dslextreme.com> wrote:
> 
> Log4j 2 won’t find that because it is config/log4j2.xml and it is looking for log4j2.xml on the classpath.
> 
> Ralph
> 
>> On Dec 14, 2017, at 11:07 AM, sherryhw <sh...@gmail.com> wrote:
>> 
>> It is in "target/classes/config/log4j2.xml"
>> Is this what you mentioned?
>> 
>> 
>> 
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>> 
> 
> 
> 



Re: What is the path for Log4j configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
Log4j 2 won’t find that because it is config/log4j2.xml and it is looking for log4j2.xml on the classpath.

Ralph

> On Dec 14, 2017, at 11:07 AM, sherryhw <sh...@gmail.com> wrote:
> 
> It is in "target/classes/config/log4j2.xml"
> Is this what you mentioned?
> 
> 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
> 



Re: What is the path for Log4j configuration?

Posted by sherryhw <sh...@gmail.com>.
It is in "target/classes/config/log4j2.xml"
Is this what you mentioned?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: What is the path for Log4j configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
Do you have a log4j2.xml on your classpath?

Ralph


> On Dec 14, 2017, at 11:04 AM, sherryhw <sh...@gmail.com> wrote:
> 
> Thanks.
> However I checked the log4j 2 is in my pom and it is in my classpath. So I
> guess it is not this cause?
> Sherry
> 
> 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
> 



Re: What is the path for Log4j configuration?

Posted by sherryhw <sh...@gmail.com>.
Thanks.
However I checked the log4j 2 is in my pom and it is in my classpath. So I
guess it is not this cause?
Sherry



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: What is the path for Log4j configuration?

Posted by Rajarshi Pain <ra...@gmail.com>.
Hello,
Check if you have log4j jar in build path? I guess jar is missing.

Thanks,
Raj

On Thu 14 Dec, 2017, 23:22 sherryhw, <sh...@gmail.com> wrote:

> Hi guys,
> I am using Log4j2 for Ignite logging, but I always have this error:
> "* Failed to instantiate [org.apache.ignite.logger.log4j2.Log4J2Logger]:
> Constructor threw exception; nested exception is class
> org.apache.ignite.IgniteCheckedException: Log4j configuration path was not
> found:config/log4j2.xml*"
>
> This is my configuration.
> *data-node-config.xml*
> <bean class="org.apache.ignite.configuration.IgniteConfiguration">
>         <property name="gridLogger">
>             <bean class="org.apache.ignite.logger.log4j2.Log4J2Logger">
>                 <constructor-arg type="java.lang.String"
> value="config/log4j2.xml"/>
>             </bean>
>         </property>
> </bean>
> And my log4j2.xml locates in the same folder as data-node-config.xml. Both
> of them are in config folder.
> File structure:
> --src
>   |--main
>     |--java
>       |--DataNodeStartUp.java
>     |--resources
>       |--config
>          |--data-node-config.xml
>          |--log4j2.xml
> However, whenever I run DataNodeStartUp.java main method to call "Ignite
> ignite = Ignition.start("config/data-node-config.xml");" to start my
> data-node, it always has the error for cannot find the  Log4j configuration
> path.
> If I use the absolute path it can work. So there is nothing wrong with my
> other configurations. What is this relative path of log4j2.xml?
>
> Thanks!
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
-- 

Thanks
Rajarshi