You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Davanum Srinivas (JIRA)" <ji...@apache.org> on 2006/05/15 17:11:06 UTC

[jira] Created: (AXIS2-734) Log4j settings and configuration

Log4j settings and configuration
--------------------------------

         Key: AXIS2-734
         URL: http://issues.apache.org/jira/browse/AXIS2-734
     Project: Apache Axis 2.0 (Axis2)
        Type: Bug

    Reporter: Davanum Srinivas


Original email:
http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e

1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
properly configured.
When running WSDL2Java.bat, the following warning is displayed:
        log4j:WARN No appenders could be found for logger 
(org.apache.axis2.i18n.ProjectResourceBundle).
        log4j:WARN Please initialize the log4j system properly.

To fix this, add the following line:
        set 
AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf

into the WSDL2Java.bat file, after these lines:
        rem loop through the libs and add them to the class path
        set AXIS2_CLASS_PATH=%AXIS2_HOME%
        FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c

%AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
log4j.properties file.

14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
the ability for the developers to change the logging level of their 
classes.
I have included a modified log4j.properties file that actually allows me 
to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
at their levels.


15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
logging, not Log4J.xml
Log4J can be configured using either a properties or an xml file.  There 
is a growing number of Logging capabilities that are only configurable 
using the XML file.  The code that sets up configuration of Log4J in Axis2 
should allow for both types of configuration files.


16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
Log4J
Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
to monitor its configuration file and automatically apply changes made to 
that file to its configuration.  This means that if support personnel need 
to modify the logging configuration of a production application, only the 
log4j configuration file needs to be modified and the Application server 
does not need  to be restarted.

Following is a snippet of code for a Log4jUtils class that addresses 
Annoyances 15 and 16.
The configureAndWatch method of this utility class should be called by an 
initialization servelet or some other configuration and initialization 
class.

------

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.helpers.FileWatchdog;
import org.apache.log4j.net.SyslogAppender;
import org.apache.log4j.xml.DOMConfigurator;

    .
    .
    .
/**
 * A collection of static utility methods for logging with Log4J.
 */
public final class Log4jUtils {
    private static final Logger LOG = 
Logger.getInstance(Log4jUtils.class);
    private static loggingConfigured = false;

    private Log4jUtils() {
        // All methods are static, this class should not be instantiated
    }

    .
    .
    .

    /**
     * Implements configureAndWatch for the current ClassLoader hierarchy 
using the Log4J
     * default number of seconds.
     */
    public static void configureAndWatch() {
        configureAndWatch(FileWatchdog.DEFAULT_DELAY);
    }
 
    /**
     * Implements configureAndWatch for the current ClassLoader hierarchy.
     * 
     * @param watchMillisecs The number of milliseconds to wait between 
checking to see if the 
     * log4j configuration file has changed.
     */
    public static void configureAndWatch(long watchMillisecs) {
        if (loggingConfigured) return;

        Class myClass = Log4jUtils.class;
        ClassLoader classLoader = myClass.getClassLoader();

        // Initialize LOG4J
        URL resourceUrl = classLoader.getResource("log4j.xml");
        if (resourceUrl != null) {
            String configFile = resourceUrl.getFile();
            DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
        } else {
            resourceUrl = classLoader.getResource("log4j.properties");
            if (resourceUrl != null) {
                String configFile = resourceUrl.getFile();
                PropertyConfigurator.configureAndWatch(configFile, 
watchMillisecs);
            } else {
                // Since we aren't going to be able to pull our "real" 
settings,
                // let's at least make sure we get some output 
                BasicConfigurator.configure();

                // Log an error with detail regarding the problem (and 
suspected cause)
                LOG.error(myClass.getName(), "Unable to find log4j.xml or 
log4j.properties. " + 
                                             "Make sure the log4j 
configuration file is in the Classpath.");
            }
        }
        loggingConfigured = true;
    }




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXIS2-734) Log4j settings and configuration

Posted by "Mike McAngus (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/AXIS2-734?page=comments#action_12416536 ] 

Mike McAngus commented on AXIS2-734:
------------------------------------

Unfortunately Jalopy, which is used to do the pretty printing of the Java Source files, requires Log4J.

If Jalopy is also removed from the lib directory, then Warnings are displayed saying 
    INFO: Jalopy not found - unable to pretty print <fully qualified generated source file name>
and the resulting Source Files are not pretty.

So, it appears that pulling the log4j.jar from the distribution and leaving out jalopy.jar (which, AFAICT, has not been distributed with Axis2 since before version 0.9.4) from the distribution is a less than optimal solution.  Perhaps you may want to revisit the idea of searching the Classpath for a Log4J configuration file (both log4j.xml and log4j.properties).

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Eran Chinthaka

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-734) Log4j settings and configuration

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/AXIS2-734?page=comments#action_12402326 ] 

Davanum Srinivas commented on AXIS2-734:
----------------------------------------

log4j properties is here:
http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/raw/%3COF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3E/5


> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXIS2-734) Log4j settings and configuration

Posted by "Mike McAngus (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/AXIS2-734?page=comments#action_12416288 ] 

Mike McAngus commented on AXIS2-734:
------------------------------------

As of the 14Jun2006 nightly build, it is still in wsdl2Java.

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Eran Chinthaka

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Assigned: (AXIS2-734) Log4j settings and configuration

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/AXIS2-734?page=all ]

Deepal Jayasinghe reassigned AXIS2-734:
---------------------------------------

    Assign To: Ajith Harshana Ranabahu

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Ajith Harshana Ranabahu

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXIS2-734) Log4j settings and configuration

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/AXIS2-734?page=comments#action_12416294 ] 

Davanum Srinivas commented on AXIS2-734:
----------------------------------------

Please remove log4j.jar and you will not see #1

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Eran Chinthaka

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Assigned: (AXIS2-734) Log4j settings and configuration

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/AXIS2-734?page=all ]

Deepal Jayasinghe reassigned AXIS2-734:
---------------------------------------

    Assign To: Eran Chinthaka  (was: Ajith Harshana Ranabahu)

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Eran Chinthaka

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXIS2-734) Log4j settings and configuration

Posted by "Anitha (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12682622#action_12682622 ] 

Anitha commented on AXIS2-734:
------------------------------

I am still facing this issue in Axis2 1.4.1 Can you please give me the steps to resolve this issue? 
16. Annoyance Axis2 does not use ConfigureAndWatch capabilities of 
Log4J
Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
to monitor its configuration file and automatically apply changes made to 
that file to its configuration. This means that if support personnel need 
to modify the logging configuration of a production application, only the 
log4j configuration file needs to be modified and the Application server 
does not need to be restarted.


> Log4j settings and configuration
> --------------------------------
>
>                 Key: AXIS2-734
>                 URL: https://issues.apache.org/jira/browse/AXIS2-734
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>            Reporter: Davanum Srinivas
>            Assignee: Eran Chinthaka
>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AXIS2-734) Log4j settings and configuration

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/AXIS2-734?page=all ]
     
Davanum Srinivas resolved AXIS2-734:
------------------------------------

    Resolution: Fixed

we don't really need log4j. gettting rid of it.

thanks,
dims

> Log4j settings and configuration
> --------------------------------
>
>          Key: AXIS2-734
>          URL: http://issues.apache.org/jira/browse/AXIS2-734
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>     Reporter: Davanum Srinivas
>     Assignee: Eran Chinthaka

>
> Original email:
> http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200605.mbox/%3cOF220CACBE.411DB84B-ON8525716B.0074F142-8525716B.007C5C4F@wendys.com%3e
> 1.   Annoyance:  WSDL2Java.bat issues a warning because Log4J cannot be 
> properly configured.
> When running WSDL2Java.bat, the following warning is displayed:
>         log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.i18n.ProjectResourceBundle).
>         log4j:WARN Please initialize the log4j system properly.
> To fix this, add the following line:
>         set 
> AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;%AXIS2_HOME%\modules\core\conf
> into the WSDL2Java.bat file, after these lines:
>         rem loop through the libs and add them to the class path
>         set AXIS2_CLASS_PATH=%AXIS2_HOME%
>         FOR %%c in ("%AXIS2_HOME%\lib\*.jar") DO set 
> AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
> %AXIS2_HOME%\modules\core\conf is the location of the Axis2-distributed 
> log4j.properties file.
> 14.  Annoyance:  The log4j.properties file shipped with Axis2 circumvents 
> the ability for the developers to change the logging level of their 
> classes.
> I have included a modified log4j.properties file that actually allows me 
> to put my classes into DEBUG level while leaving Axis2 and Tomcat logging 
> at their levels.
> 15.  Annoyance:  Axis2 only allows for Log4J.properties to configure 
> logging, not Log4J.xml
> Log4J can be configured using either a properties or an xml file.  There 
> is a growing number of Logging capabilities that are only configurable 
> using the XML file.  The code that sets up configuration of Log4J in Axis2 
> should allow for both types of configuration files.
> 16.  Annoyance:  Axis2 does not use ConfigureAndWatch capabilities of 
> Log4J
> Log4J can be configured using a ConfigureAndWatch method that causes Log4J 
> to monitor its configuration file and automatically apply changes made to 
> that file to its configuration.  This means that if support personnel need 
> to modify the logging configuration of a production application, only the 
> log4j configuration file needs to be modified and the Application server 
> does not need  to be restarted.
> Following is a snippet of code for a Log4jUtils class that addresses 
> Annoyances 15 and 16.
> The configureAndWatch method of this utility class should be called by an 
> initialization servelet or some other configuration and initialization 
> class.
> ------
> import org.apache.log4j.BasicConfigurator;
> import org.apache.log4j.PropertyConfigurator;
> import org.apache.log4j.helpers.FileWatchdog;
> import org.apache.log4j.net.SyslogAppender;
> import org.apache.log4j.xml.DOMConfigurator;
>     .
>     .
>     .
> /**
>  * A collection of static utility methods for logging with Log4J.
>  */
> public final class Log4jUtils {
>     private static final Logger LOG = 
> Logger.getInstance(Log4jUtils.class);
>     private static loggingConfigured = false;
>     private Log4jUtils() {
>         // All methods are static, this class should not be instantiated
>     }
>     .
>     .
>     .
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy 
> using the Log4J
>      * default number of seconds.
>      */
>     public static void configureAndWatch() {
>         configureAndWatch(FileWatchdog.DEFAULT_DELAY);
>     }
>  
>     /**
>      * Implements configureAndWatch for the current ClassLoader hierarchy.
>      * 
>      * @param watchMillisecs The number of milliseconds to wait between 
> checking to see if the 
>      * log4j configuration file has changed.
>      */
>     public static void configureAndWatch(long watchMillisecs) {
>         if (loggingConfigured) return;
>         Class myClass = Log4jUtils.class;
>         ClassLoader classLoader = myClass.getClassLoader();
>         // Initialize LOG4J
>         URL resourceUrl = classLoader.getResource("log4j.xml");
>         if (resourceUrl != null) {
>             String configFile = resourceUrl.getFile();
>             DOMConfigurator.configureAndWatch(configFile, watchMillisecs);
>         } else {
>             resourceUrl = classLoader.getResource("log4j.properties");
>             if (resourceUrl != null) {
>                 String configFile = resourceUrl.getFile();
>                 PropertyConfigurator.configureAndWatch(configFile, 
> watchMillisecs);
>             } else {
>                 // Since we aren't going to be able to pull our "real" 
> settings,
>                 // let's at least make sure we get some output 
>                 BasicConfigurator.configure();
>                 // Log an error with detail regarding the problem (and 
> suspected cause)
>                 LOG.error(myClass.getName(), "Unable to find log4j.xml or 
> log4j.properties. " + 
>                                              "Make sure the log4j 
> configuration file is in the Classpath.");
>             }
>         }
>         loggingConfigured = true;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira