You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Atte A <at...@hotmail.com> on 2001/08/15 14:00:54 UTC

SocketAppender Design

Hi!
I hope someone can help me and I also hope that I described everything 
understandably.

I'm describing below how I designed our logging with Log4J. I wonder if the 
design is good ENOUGH and if it could be considered PRODUCTION READY. The 
design that I have seems to work well.

Our environement is Webspere Application Server. I have a log file per 
application server in WAS. I send log messages from clients through 
SocketAppender to SocketServer and in SocketServer i have defined one 
appender for each category in generic.lcf.

I have the following class that makes the logging (uses Log4J):

public abstract class Trace
{
  String applicationserver;
  static
  {
    init();
  }
}

This function is called once for each application server in WAS:

private static void Trace::init()
{
  // Get the name of the appServer.
  applicationserver = getApplicationServer();
  PropertyConfigurator.configure("SocketServer.lcf");
}

This function is then called everytime a logging is made:

public static void Log(String loggMsg)
{
   Category cat = Category.getInstance(applicationServer);

   NDC.push("  Log");

   cat.info(loggMsg);

   NDC.pop();
}

The property configuration file SocketServer.lcf:

log4j.debug=true
log4j.rootCategory=DEBUG, SOCKETSERV
log4j.category.org.apache.log4j.net=DEBUG
log4j.appender.SOCKETSERV=org.apache.log4j.net.SocketAppender
log4j.appender.SOCKETSERV.RemoteHost=localhost
log4j.appender.SOCKETSERV.Port=9941

I start the SocketServer with the following command line arguments:
9941 E:\prop\server1.lcf E:\prop\

Then I have generic.lcf in "E:\prop" where I have one category for each 
application server and one appender for each category:

# Category NyttjaTrace
log4j.category.NyttjaTrace=debug, NyttjaTraceLog
log4j.appender.NyttjaTraceLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.NyttjaTraceLog.File=E:\\NyttjaTrace.log
log4j.appender.NyttjaTraceLog.DatePattern='.'yyyy-MM-dd
log4j.appender.NyttjaTraceLog.layout=org.apache.log4j.PatternLayout
log4j.appender.NyttjaTraceLog.layout.ConversionPattern=Time:		%d{HH:mm:ss.SSS}%n%mThread:		%t%n%x%n%n


------------------
BEST REGARDS
Atay, System developer at an insurance company in Sweden.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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