logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guangxing luo <guangxing....@gmail.com>
Subject Re: log4j paused?
Date Thu, 16 Apr 2009 02:40:16 GMT
Hi, Yair, thanks.

Below is the piece of code to handle Que message.

****************************************************************************
import javax.ejb.*;
import javax.jms.*;
import weblogic.ejb.*;
import weblogic.ejbgen.Constants;
import weblogic.ejbgen.EjbLocalRef;
import weblogic.ejbgen.EjbLocalRefs;
import weblogic.ejbgen.MessageDriven;

@MessageDriven(clientsOnSameServer = Constants.Bool.TRUE,
               maxBeansInFreePool = "1000",
               initialBeansInFreePool = "40",
               defaultTransaction =
MessageDriven.DefaultTransaction.NOT_SUPPORTED,
               transactionType =
MessageDriven.MessageDrivenTransactionType.CONTAINER,
               ejbName = "ValidatorMessenger",
	destinationJndiName = "bapid.queue.InterfaceQueue",
	destinationType = "javax.jms.Queue"


public class ValidatorMessenger
        extends GenericMessageDrivenBean
        implements MessageDrivenBean, MessageListener
{


    public void onMessage(Message msg) {

       // more codes are not list here.
       BapidLogger.debug("|| ValidatorMessenger || onMessage ||
TransactionID:" + transactionIDMsg + ":"+"The parameters are :"
+transactionID + "<" + messageArray[1] + ">");
       //start other process
  }
}

************************************************************************
public class BapidLogger {
    private static Logger loggerdebug = null;
    private static Logger loggererr = null;

    public static void init()
    {
        loggerdebug = BapidBatchLogger.getInstance("rapiddebug", "");
        loggererr = BapidBatchLogger.getInstance("rapiderr", "");
    }

    /**
     * for debug messages
     * @param msg Object instance
     */
    public static void debug (Object msg)
    {
        if (loggerdebug==null)
            init();

        loggerdebug.debug(msg);
    }
}

*****************************************************

import java.util.Hashtable;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggerFactory;
import org.apache.log4j.PropertyConfigurator;


public class BapidBatchLogger {

    private static String rapidlogging =
System.getProperty("bapid.logging.config");

    private static Hashtable ht_logger = new Hashtable();

    public static void init(){
        PropertyConfigurator.configure(rapidlogging);
    }

    public static Logger getInstance(String name, String prop)
    {
        if (ht_logger.containsKey(name))
        {
            Logger log = (Logger) ht_logger.get(name);
            if(log==null)
            {
                BapidLogger.error("|| BapidBatchLogger || getInstance
|| Property Not Found");
            }
            return log;
        }
        else
        {
            PropertyConfigurator.configure(rapidlogging);

            Logger templogger = Logger.getLogger(name);
            ht_logger.put(name, templogger);
        }

        Logger log = (Logger) ht_logger.get(name);
        if(log==null)
        {
            BapidLogger.error("|| BapidBatchLogger || getInstance ||
Property Not Found");
        }
        return log;
    }
}
// End of BapidBatchLogger.java

************************************************

We are using central log handle class BapidLogger.   We put 20,000
transactions to message queue,  and message EJB will concurrently
process these messages.
Quite a few transactions can not be found in log file, although the
database updates are done successfully.  As log4j is thread safe, I do
not think it is necessary to synchronize the
log calling BapidLogger.debug("....").

Online log file missing issue is solved, as we have cluster Weblogic
application servers, those online log not  found in server 1 are found
in server 2.


On Thu, Apr 16, 2009 at 2:44 AM, Yair Ogen <yairogen@gmail.com> wrote:
> Do you type the thread name in your logs? To to add it and analyze the log
> file. I have found in the past the in some not thread safe application to
> events tries to write a log message at the same time resulting in only one
> log message being written.
>
> Can this be your case?
>
>
> On Mon, Apr 13, 2009 at 9:35 AM, guangxing luo <guangxing.luo@gmail.com>wrote:
>
>> Hi there,
>>
>> We have web application running in weblogic 9.2 MP2, using log4j as
>> log tool in Sun Solaris 10.  We are using central tool class to log
>> debug message.
>>
>> At night, we have a batch job to read 20k transactions from table, and
>> insert these transactions into JMS Queue.  Message EJB will process
>> concurrently.  The transaction ID for each transaction is logged by
>> central log class. However, we found not all of 20K transaction are
>> logged.  For online module, we also found some
>> log message can not be found.  It seems as if log4j is hang at some
>> moment or 'paused'.
>>
>> Appreciate any sharing.
>>
>> luo
>>
>> Below is log4j configuration file used.
>>
>> #Do not change this --------------------------------------------
>> #log4j.loggerFactory=com.XXX.bapid.common.BapidLoggerFactory
>> #log4j.rootCategory=DEBUG
>> log4j.rootLogger=INFO,A1
>> #---------------------------------------------------------------
>>
>> #Default Logger
>> log4j.appender.A1=org.apache.log4j.ConsoleAppender
>> log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>> log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
>>
>>
>> log4j.logger.rapiddebug=DEBUG, A_BAPIDDEBUG
>> log4j.appender.A-BAPIDDEBUG=org.apache.log4j.DailyRollingFileAppender
>> log4j.appender.A-BAPIDDEBUG.layout=org.apache.log4j.PatternLayout
>> log4j.appender.A-BAPIDDEBUG.layout.ConversionPattern=%d %m%n
>> log4j.appender.A-BAPIDDEBUG.File=/data01/bapid/logs/bapid_debug.log
>> log4j.appender.A-BAPIDDEBUG.DatePattern='.'yyyy-MM-dd
>> log4j.additivity.bapiddebug=false
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message