Hallo Guy,

we have developed a servlet which is loaded at the startup of orion
(via the <load-on-startup>1</load-on-startup> in the
servlet-definition in web.xml) and initialises the log4j-framework
according to a properties-file. 

This will set up the loging-configuration globally, though...

greetings
   Rob


---------SOURCE AHEAD-------------

package com.scaraboo.logging;

import javax.servlet.http.*;
import org.apache.log4j.*;

/**
 * Title:        Log4jInitServlet initializes log4j-logging for JSP.
 * Description:  This servlet should be loaded at startup, definition in
 *               /WEB-INF/web.xml:
 *               <pre>
 *&lt;?xml version="1.0"?&gt;
 *&lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" 
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"&gt;
 *
 *&lt;web-app&gt;
 * &lt;servlet&gt;
 *    &lt;servlet-name&gt;log4j-init&lt;/servlet-name&gt;
 *    &lt;servlet-class&gt;com.scaraboo.logging.Log4jInitServlet&lt;/servlet-class&gt;
 *    &lt;init-param&gt;
 *      &lt;param-name&gt;cfg_file&lt;/param-name&gt;
 *      &lt;param-value&gt;logging.cfg&lt;/param-value&gt;
 *    &lt;/init-param&gt;
 *    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
 * &lt;/servlet&gt;
 *&lt;/web-app&gt;
 *               </pre>
 * Copyright:    Copyright (c) 2001
 * Company:      scaraboo GmbH
 * @author Robert Virkus, [EMAIL PROTECTED]
 * @version 1.0
 * @see <a 
href="http://jakarta.apache.org/log4j/docs/documentation.html";>http://jakarta.apache.org/log4j</a>
 */

public class Log4jInitServlet extends HttpServlet {

        private static Category LOG = Category.getInstance( 
Log4jInitServlet.class.getName() );

        public void init() {
                String cfgpath = "logging.cfg";
                if (getInitParameter( "cfg_file" ) != null)
                         cfgpath = getInitParameter( "cfg_file" );
                PropertyConfigurator.configure( cfgpath );
                LOG.info("logging configuration is set according to configuration-file 
[" + cfgpath + "]." );
        }

        public void doGet( HttpServletRequest req, HttpServletResponse resp ) {
                // do nothing, servlet should just be loaded at startup
        }
}


Thursday, January 31, 2002, 7:15:09 PM, you wrote:


DGTL> Well I've followed all these instructions but have fallen over on a couple
DGTL> of counts:

DGTL> 1- Using a BasicConfigurator, which is initialised within a singleton,
DGTL> nothing is displayed, it's as if log4j has gobbled up all my messages :-(
DGTL> 2- If I try and use a DOMConfigurator it can't find the config file.

DGTL> Help anyone?

DGTL> Thanks,
DGTL> Guy :-(

DGTL> -----Original Message-----
DGTL> From: Scott Farquhar [mailto:[EMAIL PROTECTED]]
DGTL> Sent: 22 January 2002 01:28
DGTL> To: Orion-Interest
DGTL> Subject: Re: Integrating LOG4J into Orion...


DGTL> Further to what Mike has said, I'll just give you a little update on the 
DGTL>   status of the Log4j 1.2 release.

DGTL> The 1.2 code base is largely different to the 1.1 base, and has features 
DGTL> that when finished, will be useful for using in application servers, and 
DGTL> make it a lot easier to configure.

DGTL> The features that I talk about are:

DGTL> - Different LogManagers.
DGTL> This will allow Orion to provide a logmanager *per application*, or if 
DGTL> it can't find one, use the default logmanager.  This means that you will 
DGTL> be able to specify a configuration file per application, and not have to 
DGTL> manually configure it.

DGTL> - Configuration files will be reloaded
DGTL> The "watchers" code is being rewritten.  When it is finished, you will 
DGTL> most likely have code that allows you to configure how often the config 
DGTL> files are reloaded (and stop / restart the watcher thread).

DGTL> So what does this mean for you, if you are using log4j in your 
DGTL> application now?

DGTL> - Use the 1.2 code.  Although in alpha, it is quite stable.
DGTL> - If you have specific requirements (apart from the above two), suggest 
DGTL> them on the log4j email list, or email me with your suggestions.

DGTL> Lastly - congratulations on using log4j.  Logging is very important in 
DGTL> enterprise applications!

DGTL> Cheers,
DGTL> Scott



Mit freundlichen Grüßen,
  Robert Virkus
  Director Mobile Solutions

-- 
Robert Virkus
scaraboo GmbH
mobile Entertainment
Georg-Wulf-Str.4-6
28199 Bremen
Germany
phone  +49 - (0)421 - 59 67 549
fax    +49 - (0)421 - 59 67 567
mobile +49 - (0)171 - 35 31 635
[EMAIL PROTECTED]
www.scaraboo.de
wap.scaraboo.de

----------------------------
Aus Rechts- und Sicherheitsgruenden ist die in dieser E-Mail gegebene
Information nicht rechtsverbindlich. Eine rechtsverbindliche Bestaetigung
reichen wir Ihnen gerne auf Anforderung in schriftlicher Form nach. Beachten
Sie bitte, dass jede Form der unautorisierten Nutzung, Veroeffentlichung,
Vervielfaeltigung oder Weitergabe des Inhalts dieser E-Mail nicht gestattet
ist. Diese Nachricht ist ausschliesslich fuer den bezeichneten Adressaten
oder dessen Vertreter bestimmt. Sollten Sie nicht der vorgesehene Adressat
dieser E-Mail oder dessen Vertreter sein, so bitten wir Sie, sich mit dem
Absender der E-Mail in Verbindung zu setzen.
----------------------------
For legal and security reasons the information provided in this e-mail is
not legally binding. Upon request we would be pleased to provide you with a
legally binding confirmation in written form. Any form of unauthorised use,
publication, reproduction, copying or disclosure of the content of this
e-mail is not permitted. This message is exclusively for the person
addressed or their representative. If you are not the intended recipient of
this message and its contents, please notify the sender immediately.


Reply via email to