Friday, September 17, 2010

Log4j observation and best practice

Just today I realized that setting the Threshold value for logging level at appender has no effect on checking if lower levels are enabled for particular category.

For example consider the log4j.xml config file as shown below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<param name="Threshold" value="INFO" />

<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" />
</layout>
</appender>

<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<!-- ADD HOME VAR HERE? -->
<param name="File" value="../log/server.log" />
<param name="Append" value="false" />
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<!--
The default pattern: Date Priority [Category] (Thread) Message\n
-->
<param name="ConversionPattern" value="%d %-5p [%c{1}] (%t) %m%n" />

<!--
The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x)
%m%n"/>
-->
</layout>
</appender>

<category name="org.mobicents.media.server">
<priority value="INFO"/>
</category>
<category name="org.mobicents.media.server.impl.rtp">
<priority value="TRACE"/>
</category>

<root>
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>

</log4j:configuration>



And in org.mobicents.media.server.impl.rtp.JitterBuffer class I have a check

if (logger.isTraceEnabled()) {
logger.trace("Receive " + packet);
}


What would you expect the 'isTraceEnabled()' to return? false? I too assumed same. But I was wrong. It returns true. So log4j will still create StringBuffer and appends objects to it to create the log statement and call .toString() on StringBuffer only to realize the appender has Threshold logging level higher than TRACE and it will drop this log message :(


So setting Threshold value only doesn't help in production environment. Make sure that you change logging level of individual Category too.

Sunday, September 12, 2010

Mobicents Face-2-Face 2010 at Antalya, Turkey from 24th Sept to 30th Sept

Its time of the year when Mobicents developer from across the world meet at one common place and brain storm on road-map for next year, achievement of past year, experiences, prospects etc. The annual Mobicents Face-2-Face was only for team members till now, but like true Open Source Spirit we have opened this meeting to all users, partners, or even non-users who wants to participate and get the understanding of Mobicents Project and how core team functions. We already have three partners visiting this meeting for this year.

However its not as boring as it sounds. Every evening after hectic day the team visits the best and lively attraction of the city and freaks out, sometimes till next day morning! Don't believe me? Look at blogs and picture from last year meeting http://groups.google.com/group/mobicents-public/web/mobicents-dev-team-meeting---brno-august-2009

The meet is happening at Antalya, Turkey from 24th Sept 2010 to 30th Sept 2010. If interested in participating follow the public post http://groups.google.com/group/mobicents-public/browse_thread/thread/d59873fbdd142f96/00e654830423ad4a?lnk=raot#00e654830423ad4a

Hope to see you guys @ Antalya :)

A week at Meraka, CSIR


Last week Bartek and I had privilege to conduct Mobicents Platform training at Meraka, Council for Scientific and Industrial Research (CSIR) Institute located in city of Pretoria, South Africa. The CSIR is South Africa's central and premier scientific research and development organisation in Africa. Constituted by an Act of Parliament in 1945 as a science council, the CSIR undertakes directed and multidisciplinary research, technological innovation as well as industrial and scientific development to improve the quality of life of the country’s people.


Institute is built across beautiful campus and rich with facilities; I was amazed to see the CSIR Institute and made me remind IIT-K Campus that I visited this February.




Usually training's are too boring to conduct with flow of knowledge happening just in one direction. But this was a rare training where audience were very interactive and made Bartek/me think twice before we could really answer their queries.

Meraka has already developed couple of JSLEE Resource Adaptor's (on Mobicents 1.x.y Platform) for proprietary protocol communicating with SMSC and USSD aggregator. These RA's are used in platform called MOBI4D. The presentation explaining the MOBI4D is here http://sport.csir.co.za/view.aspx?id=2382~4p~QczxuuJq


Meraka already have several exciting projects ongoing specifically on TTS, ASR, IVR, IP Tv. It will be very exciting to see these projects go live by end of next year.

Looking forward to visit SA again soon and spend more time with this team!