Hazelcast Server Setup for Log4j or custom Logging? (Server Side logging)

944 views
Skip to first unread message

Benjamin E.Ndugga

unread,
Nov 15, 2016, 2:05:38 PM11/15/16
to Hazelcast


 I have copied the log4j-1.2.17.jar in the lib/ folder and have added it to the classpath as shown in the start.sh script and i have added the property for the logging type to log4j with the Configuration file all shown below. However all has failed to work.

Can someone see where the problem is?

<?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="/opt/hz-file.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>



 <property name="hazelcast.logging.type">Log4j</property>


#### maximum heap size
MAX_HEAP_SIZE
=1G

if [ "x$MIN_HEAP_SIZE" != "x" ]; then
        JAVA_OPTS
="$JAVA_OPTS -Xms${MIN_HEAP_SIZE}"
fi

if [ "x$MAX_HEAP_SIZE" != "x" ]; then
        JAVA_OPTS
="$JAVA_OPTS -Xmx${MAX_HEAP_SIZE}"
fi

JAVA_OPTS
="$JAVA_OPTS -Dhazelcast.logging=log4j"
JAVA_OPTS
="$JAVA_OPTS -Dlog4j.configurationFile=log4j.xml"

echo
"########################################"
echo
"# RUN_JAVA=$RUN_JAVA"
echo
"# JAVA_OPTS=$JAVA_OPTS"
echo
"# starting now...."
echo
"########################################"

PID
=$(cat "${PID_FILE}");
if [ -z "${PID}" ]; then
    echo
"Process id for hazelcast instance is written to location: {$PID_FILE}"
        $RUN_JAVA
-server -cp "../lib/*"  $JAVA_OPTS com.hazelcast.core.server.StartServer &
    echo $
! > ${PID_FILE}
else
    echo
"Another hazelcast instance is already started in this folder. To start a new instance, please unzip 3.6.zip/tar.gz in a new folder."
   
exit 0
fi


Jaromir Hamala

unread,
Nov 15, 2016, 2:38:03 PM11/15/16
to Hazelcast
Hi Benjamin,

can you try to use 

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

=with the lower-case initial l ?

Cheers,
Jaromir

Benjamin E.Ndugga

unread,
Nov 15, 2016, 2:54:50 PM11/15/16
to Hazelcast
Hi Jaromir,

Thank you soo much, the server can now read the the property change, but here is how it gets interesting from the output that I get, it seems my log4j.xml file can not be seen even after adding it to the JAVA_OPTS

[benjamin@oc6807683863 bin]$ ./start.sh
JAVA_HOME found at
/opt/jdk1.7.0_79
Path to Java : /opt/jdk1.7.0_79/bin/java
########################################
# RUN_JAVA=/opt/jdk1.7.0_79/bin/java
# JAVA_OPTS= -Xmx1G -Dlog4j.configurationFile=log4j.xml
# starting now....
########################################
cat
: /home/benjamin/APIs/Hazelcast/hazelcast-3.6/bin/hazelcast_instance.pid: No such file or directory
Process id for hazelcast instance is written to location: {/home/benjamin/APIs/Hazelcast/hazelcast-3.6/bin/hazelcast_instance.pid}
[benjamin@oc6807683863 bin]$ Nov 15, 2016 10:52:59 PM com.hazelcast.config.XmlConfigLocator
INFO
: Loading 'hazelcast.xml' from working directory.
log4j
:WARN No appenders could be found for logger (com.hazelcast.instance.DefaultAddressPicker).
log4j
:WARN Please initialize the log4j system properly.
log4j
:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.


Regards
Benjamin

Jaromir Hamala

unread,
Nov 15, 2016, 3:02:33 PM11/15/16
to Hazelcast
I am not a log4j expert, but you can try something like this:
-Dlog4j.configuration=file:"/absolute/path/log4j.xml"

If this is working then you can experiment with relative path to make it more portable.

Cheers,
Jaromir

Benjamin E.Ndugga

unread,
Nov 15, 2016, 3:17:17 PM11/15/16
to Hazelcast
 Hi Jaromir,

I have managed to make it work, thank u soo much

soo here is the new configuration line:

JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:///home/benjamin/APIs/Hazelcast/hazelcast-3.6/bin/log4j.xml"



It as worked !!!!!!!!!!!!!!!


Regards

Jaromir Hamala

unread,
Nov 15, 2016, 3:19:43 PM11/15/16
to haze...@googlegroups.com
Hi Benjamin,

that's great to hear! Happy Hazelcasting!

J.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+unsubscribe@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/ff464932-6a32-41d1-a47b-26aa97f59153%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages