Hello

Am Fri, 7 Aug 2009 07:44:06 +0200
schrieb Christian Grobmeier <[email protected]>:

> Hi all,
> 
> based on Christian Hammers Issue #56 I have made some thoughts.
> 
> Currently, the initialization of Log4PHP is not objectoriented. Its
> some procedural code at the of the Logger script.
> Flow is that the script checks for some enviroment fields, creates the
> f. e. Configurator class and calls configure on that.
> The configurator class does its stuff and calls usually some static
> Logger methods. F.e. the ConfiguratorIni is calling
> the Logger::getHierarchy which is calling the
> LoggerHierarchy::singleton method.
> 
> You see, this is all quite confusing and complex.
> 
> The fields, which configure Log4PHP are deprecated in Log4J, stating
> they are gonna to be private.
> 
> I think the good initialization would be something like this:
> 
> Logger::setConfiguraton('properties.xml');
> Logger::setConfiguraton('MyClass');
> Logger::initialize();
> Logger::getLogger('mylogger');
> 
> The initialize() method can be done hidden by the first call of a
> method like getLogger or getRootLogger or whatelse. It could be done
> by default, but disabled by a flag for manual configuration.
> This way we don't need the fields (except the "disable auto
> initialization") anymore.

After reading http://logging.apache.org/log4j/1.2/manual.html I'm
wondering why we should need a setConfiguration() or those deprected
variables at all.

The only reasons so far were that you either would rather use the
BasicConfigurator than the PropertyConfigurator or would
like to specify a different properties file name. The documented
behaviour for those cases is:

   static Logger logger = Logger.getLogger(MyApp.class.getName());
    
   public static void main(String[] args) {
     // BasicConfigurator replaced with PropertyConfigurator.
     PropertyConfigurator.configure(args[0]);

or 

   public static void main(String[] args) {
     // Set up a simple configuration that logs on the console.
     BasicConfigurator.configure();

which both look as if they could be used in PHP the same way.
   
bye,

-christian-

Reply via email to