Re: Cayene logging:

From: Holger Hoffstätte (holge..izards.de)
Date: Sat Jun 07 2003 - 16:56:12 EDT

  • Next message: Andrus Adamchik: "Re: Cayene logging:"

    Andrus Adamchik wrote:
    > All you need is to call this on startup:
    >
    > Configuration.configureCommonLogging(null);
    >
    > (Need to document this trick...)

    This seems to come up quite often, so I thought it would be more
    user-friendly to find out whether log4j has already been initialized and
    just act accordingly. After some searching I found something that might do
    the trick:

    public class LoggerTest
    {
        static Logger log = Logger.getLogger(LoggerTest.class);

        public static void main(String[] args)
        {
            Logger root = Logger.getRootLogger();
            Enumeration e = root.getAllAppenders();

            if (e.hasMoreElements())
            {
                log.info("logging already configured :)");
                // just set isLoggingConfigured and proceed
            }
            else
            {
                // configure log4j as usual; the file is renamed so that
                // log4j doesn't automatically load it for this test
               
    PropertyConfigurator.configure("src/log4j.properties.disabled");
                log.info("logging configured manually!");
            }
    }

    Good idea?

    Holger



    This archive was generated by hypermail 2.0.0 : Sat Jun 07 2003 - 16:55:06 EDT