[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-user
Subject:    RE: newbie: configuring log4j for EJB's inside weblogic
From:       "Ebersole, Steven" <steven.ebersole () vignette ! com>
Date:       2003-07-31 15:45:24
[Download RAW message or body]

The init servlet code looks like:



public class LoggingInitServlet
extends javax.servlet.http.HttpServlet
{
    public LoggingInitServlet()
    {
        super();
    }

    public void init( javax.servlet.ServletConfig config ) 
    throws javax.servlet.ServletException
    {
        super.init( config );
        String logConfigPath = config.getInitParameter( "log4j.config.path"
);
        if (logConfigPath == null)
        {
            // Nothing to do...
            return;
        }

        long logWatchPeriod = 0;
        try
        {
            logWatchPeriod = Long.parseLong( config.getInitParameter(
"log4j.config.watchPeriod" ) );
        }
        catch( Exception e )
        {}

        if (logWatchPeriod > 0)
        {
            org.apache.log4j.xml.DOMConfigurator.configureAndWatch(
logConfigPath, logWatchPeriod );
        }
        else
        {
            org.apache.log4j.xml.DOMConfigurator.configure( logConfigPath );
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse
response)
    {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse
response)
    {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
    }
}



    <servlet>
        <servlet-name>LogInitializerServlet</servlet-name>
        <servlet-class>my.package.LoggingInitServlet</servlet-class>
        <init-param>
            <param-name>log4j.config.path</param-name>
            <param-value>/dir/to/configfile/log4j-init.xml</param-value>
        </init-param>
        <init-param>
            <param-name>log4j.config.watchPeriod</param-name>
            <param-value>50000</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>





-----Original Message-----
From: Andreas Bothner [ MTN - Innovation Centre ]
[mailto:bothne_a@mtn.co.za]
Sent: Thursday, July 31, 2003 8:31 AM
To: Log4J Users List
Subject: RE: newbie: configuring log4j for EJB's inside weblogic


When using option #2, are you actually using up more memory, ie:
different classloaders loading the same log4j classes, therefore the
same class is loaded into memory multiple times?  Is this a
consideration or is the only main concern flexibility?
I thought that the configuration of log4j was extremely flexible, so I
could use one configuration file for all apps.

Please don't forget to send me your servlet code... I do appreciate it. 

-----Original Message-----
From: Steve Ebersole [mailto:steveebersole@austin.rr.com] 
Sent: Thursday, 31 July 2003 14:00
To: Log4J Users List
Subject: RE: newbie: configuring log4j for EJB's inside weblogic

You cannot hot deploy because the classes are then loaded by the
classloader
which loaded weblogic itself (i.e., typically the jvm main classloader).
Hot deployment depends on the ability to destroy and "throw away" an
entire
classloader.  This goes to how j2ee apps are deployed within their
targetted
container.  There's lots of docs around if you are interested in how
this
happens.


As a side note, you can still hot redeploy your apps.  Its just that
logging
may or may not get screwed up in that option #1 when hot redeploy.



-----Original Message-----
From: Andreas Bothner [ MTN - Innovation Centre ]
[mailto:bothne_a@mtn.co.za]
Sent: Thursday, July 31, 2003 6:54 AM
To: Log4J Users List
Subject: RE: newbie: configuring log4j for EJB's inside weblogic


Thanks Steve, I would appreciate you sending me your servlet code...

Why did you say that you cannot use hot-deploy in option #1 ???
Is it possible to have a combination of both options???

-----Original Message-----
From: Steve Ebersole [mailto:steveebersole@austin.rr.com]
Sent: Thursday, 31 July 2003 13:29
To: Log4J Users List
Subject: RE: newbie: configuring log4j for EJB's inside weblogic

>> do you have to include the log4j.jar in every ear file?
yes

>> What does the environment entry refer to?
It simply defines where to find the config file.  The other option here
is
to allow each ear file have its copy of log4j.jar and its
log4j.xml/properties in the ear on the classpath.  Then no explicit
congifuration code is needed (log4j will find the config file and
configure
itself).

>> Could you share the servlet code?
If you need, I can include it verbatim when I get to work.  Its really
using
DOMConfigurator.configure()/configureAndWatch() inside the init method.
The
servelt is mapped to load-on-startup inside its web.xml file.




-----Original Message-----
From: Andreas Bothner [ MTN - Innovation Centre ]
[mailto:bothne_a@mtn.co.za]
Sent: Thursday, July 31, 2003 3:53 AM
To: Log4J Users List
Subject: RE: newbie: configuring log4j for EJB's inside weblogic


Hi Steven,

Thank you for the response.   I thought of writing a startup class
because in option #1 the code PropertyConfigurator.configureAndWatch()
has to be called somewhere, once instead of each application doing it.

Could you give me more info on option #2 ... do you have to include the
log4j.jar in every ear file?  Could you share the servlet code?  What
does the environment entry refer to?

Regards,
Andreas

-----Original Message-----
From: Ebersole, Steven [mailto:steven.ebersole@vignette.com]
Sent: Wednesday, 30 July 2003 19:16
To: 'Log4J Users List'
Subject: RE: newbie: configuring log4j for EJB's inside weblogic

I've done two seperate setups for configuring log4j on weblogic (both
are
6.1sp4).

#1 log4j.jar and its config file on the server classpath (i.e., the
classpath built in startWebLogic.sh)

#2 Each enterprise deployable handling its own config.  In my ear, this
is
accomplished by including a war file with just a single servlet whose
sole
purpose is to configure log4j from an env-entry.


Option #1 is serviceable but not very flexible.  All classes running
within
that server must then use that configuration.  And further more, you
will
not be able to hot-deploy components.



Why write a startup class (i.e., weblogic startup class as opposed to
starup
servlet) to acheive this?  #1 does the same thing...






-----Original Message-----
From: Andreas Bothner [ MTN - Innovation Centre ]
[mailto:bothne_a@mtn.co.za]
Sent: Wednesday, July 30, 2003 12:05 PM
To: log4j-user@jakarta.apache.org
Subject: newbie: configuring log4j for EJB's inside weblogic


Hi,



I would prefer not to put the log4j jar file into each EJB application
jar file, so I have tried to put the log4j jar into the classpath and
then simply start the app server.  I expected my EJB's to find the
Logger class, but was disappointed to get a ClassNotFound Exception.  Is
it possible to use log4j without deploying the jar with each application
jar?



The other question I have is when to configure log4j.  I think it would
be overkill to put this code into each EJB implementation.  Would I be
right in thinking that I should create a startup class that the
application server runs when booting and that this class must call the
configureAndWatch() method???



Regards,

Andreas


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


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


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


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


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


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


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic