log4j configuration in hazelcast.

2,039 views
Skip to first unread message

srikalyan swayampakula

unread,
Jul 1, 2014, 8:54:11 PM7/1/14
to haze...@googlegroups.com
Hi Everyone,

I am trying to configure hazelcast to use log4j with log4j.properties/log4j.xml nothing seems to be working. I am getting this error

INFO: Using configuration file at /Users/srikalyan.swayampakula/tools/hazelcast/hazelcast-3.2.3/bin/hazelcast.xml
log4j:WARN No appenders could be found for logger (com.hazelcast.instance.DefaultAddressPicker).
log4j:WARN Please initialize the log4j system properly.

I am runnning the following command

java -server -Xms1G -Xmx1G -Djava.net.preferIPv4Stack=true -cp ../lib/hazelcast-3.2.3.jar:../lib/log4j-1.2.17.jar -Dlog4j.configurationFile=./log4j.xml com.hazelcast.examples.StartServer

with hazelcast containing 

<properties>
<property name="hazelcast.logging.type">log4j</property>
</properties>

and this is my log4j.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
                     xmlns:log4j='http://jakarta.apache.org/log4j/'>

   <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
      </layout>
   </appender>

   <appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
      <param name="append" value="false"/>
      <param name="file" value="out/learning.log"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
      </layout>
   </appender>

   <root>
      <level value="DEBUG"/>
      <appender-ref ref="consoleAppender"/>
      <appender-ref ref="fileAppender"/>
   </root>

</log4j:configuration>


Please let me know if I am doing something wrong.

Thanks in advance.

Peter Veentjer

unread,
Jul 2, 2014, 2:15:10 AM7/2/14
to haze...@googlegroups.com

On Wed, Jul 2, 2014 at 3:54 AM, srikalyan swayampakula <srikalya...@gmail.com> wrote:
log4j

Can you add the following to the commandline:

-Dlog4j.debug

This should give you additional logging debug information.

And try to use the following syntax for the logfile

-Dlog4j.configurationFile=file:/log4j.xml 

I think the lack of file:/ prefix is causing the problem.

Personally I don't configure log4j from the config file, but do it on the commandline:

-Dhazelcast.logging=log4j

This is more reliable.


srikalyan swayampakula

unread,
Jul 9, 2014, 12:21:21 PM7/9/14
to haze...@googlegroups.com
Thanks peter,

Running this worked 
{code}
java -server -cp /usr/lib/hazelcast/hazelcast.jar:/usr/lib/hazelcast/log4j.jar -Dhazelcast.config=/etc/hazelcast/hazelcast.xml -Dlog4j.configuration=file:///etc/hazelcast/log4j.properties -Dhazelcast.logging.type=log4j com.hazelcast.examples.StartServer
{code}

Problem was it was looking for configuration not configurationFile.

Just adding the note here so that it would be useful for future use.
Reply all
Reply to author
Forward
0 new messages