There is already a LogFactory that seems to do exactly as you suggest.

http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/Log
Factory.html

James
----- Original Message -----
From: "Manfred Wolff" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 15, 2002 11:09 AM
Subject: Logger Framework


>
> Hello
>
> First: The common-loggin framework is a good idea to have an abstract
layer
> over some logging APIs. The factory is also fine and I use both  in a
> comercial project.
>
> The Problem: In evry real class you have to specific, what kind of logger
> you will get. e.g.
>
> private static final Log logger = new
> Log4JCategoryLog("my.package.name.classname");
>
> or perhaps you may use the factory e.g. Log4jFactory. Just a good idea is
it
> to have a Log4JLoggerLog instead of CategoryLog!
>
> Unfortunatly it is not possible to have an abstract factory that offers
you
> a log-implementation as configured. If this were possible, you  may
> configure at a central point of your application what kind of logger you
> will have and the abstract factory may manage it by bypassing the request
to
> the real logger. Thus factory may be seen as follow:
>
> public class LoggerFactory {
>
>      static int initialized = -1;
>      public static final int SIMPLE = 1;
>      public static final int LOG4J = 2;
>
>      private int loglevel;
>      private Log4jFactory factory;
>
>     /**
>      * Initialized the logging framework
>      * @param aKind Which kind of framework is wanted
>      * @param aInitProperties Properties for the framework
>      */
>     public static void initLog(int aKind, Properties aInitProperties ) {
>
>         if (initialize != -1) return;
>
>         switch (aKind) {
>
>             case SIMPLE:
>                 Integer ilogLevel = (Integer)
aInitProperties.get("level");
>                 logLevel = ilogLevel.intValue();
>                 initialize = SIMPLE;
>                 break;
>
>             case LOG4J:
>                 PropertyConfigurator.configure(aInitProperties);
>                 initialize = LOG4J;
>                 factory = new Log4jFactory();
>                 break;
>         }
>     }
>
>
>     /**
>      * Factorymethod to get an logger as configured
>      * @param aLoggerName The name of the logger
>      * @return A Log interface
>      */
>     public static Log getLogger(String aLoggerName) {
>
>         switch (initialize) {
>             case SIMPLE: // if configured SIMPLE Log
>                 SimpleLog sl = new SimpleLog(aLoggerName);
>                 sl.setLevel(logLevel);
>                 return sl;
>             case LOG4J: // if configured Log4J
>                 return factory.getInstance(aLoggerName);
>         }
>         return new NoOpLog(aLoggerName);
>     }
>
> I think, this may be a great extension to the common-logger framework.
>
> Manfred
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.comm

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to