logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Steppe <kste...@pacbell.net>
Subject Re: AsyncAppender creating too many threads.....
Date Tue, 04 Dec 2001 02:44:51 GMT
In your TracerLogger getCategory() method, you have:
                    cat.addAppender( new AsyncAppender());
That (obviously) creates a new appender for -every- class.  Try configuring once and
putting the appender on the root category.  Obviously you don't need a different
appender for every class in your system.

Kevin

ps. This may be insulting but you probably weren't answered last time b/c you hadn't
taken 5 seconds to find your own bug.


Ajay Dhanawade wrote:

> Hi All,
>
> I had poste dthis question earlier as well. I am havinn problem with the
> AsyncAppender. We are trying to implement the log4j in our J2EE application.
> When we start the application and monitor we see 80 threads created whereas
> the Weblogic server 6.0sp1 which we are usinf spawns max 30 threads.
>
> What can be wrong ? I am using log4j version 1.2. Follwoing is the config
> file for log4j
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE configuration SYSTEM "log4j.dtd">
>
> <configuration configDebug="false">
>
>         <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
>                 <appender-ref ref="TEMP"/>
>         </appender>
>
>         <appender name="TEMP" class="org.apache.log4j.RollingFileAppender">
>             <param name="Append" value="false" />
>             <param name="Prefix" value="/bea/logs/test-" />
>             <param name="Postfix" value=".log" />
>             <param name="MaxFileSize" value="1" />
>             <param name="MaxBackupIndex" value="1" />
>                 <layout
> class="org.apache.log4j.examples.appserver.AppServerPatternLayout">
>                      <param name="ConversionPattern"
>                             value="%d %-5p [%t] %C{2} (%F:%L) - %m\n"/>
>                 </layout>
>         </appender>
>
>         <root>
>                 <priority value="debug"/>
>                 <appender-ref ref="ASYNC"/>
>         </root>
> </configuration>
>
> I have a designed a class to use log4j which is as follows:
>
> import org.apache.log4j.*;
> import org.apache.log4j.xml.*;
> import javax.servlet.http.HttpServletRequest;
> import java.io.Serializable;
>
> public class TracerLogger implements ITracerLogger,Serializable{
>         String componentName = null;
>         String sessionID = null;
>
>         public TracerLogger(String className){
>                 componentName = className;
>         }
>
>         public TracerLogger(HttpServletRequest req, String className){
>                 sessionID = req.getRequestedSessionId();
>                 componentName = className;
>         }
>
>         public Category getCategory(){
>             AppServerCategoryFactory factory;
>                 factory = new AppServerCategoryFactory("MyServer", "ActionMail",
> sessionID);
>             AppServerCategory.setFactory(factory);
>
>                 Category cat = AppServerCategory.getInstance(componentName);
>                 PatternLayout layout = new AppServerPatternLayout();
>                 cat.addAppender( new AsyncAppender());
>                 return cat;
>         }
>
>         public void debug(String message){
>                 Category cat = getCategory();
>                 cat.debug(message);
>         }
>
>         public void error(String message){
>                 Category cat = getCategory();
>                 cat.error(message);
>         }
>
>         public void info(String message){
>                 Category cat = getCategory();
>                 cat.info(message);
>         }
>
>         public void warn(String message){
>                 Category cat = getCategory();
>                 cat.warn(message);
>         }
>
>         public void fatal(String message){
>                 Category cat = getCategory();
>                 cat.fatal(message);
>         }
> }
>
> This class is instantiated in each and every class which logs the messages
> to a file.
>
> Please can anyone give me pointers on what might be the cause for so many
> threads getting created?
>
> Help is appriciated...
>
> CIAO
> Ajay
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


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


Mime
View raw message