$Revision: 1.4 $

Log4Php

Summary

Log4php is a partial php port of the most popular java logging framework log4j (see http://jakarta.apache.org/log4j/ for details).

Features

It can be used inside a class (see Usage below) or inside a main/sub function.

Requirements

Download

See Log4php Download page.

Installation

Extract tar package and copy the content of src/ tree to a php include_path directory in order to use:

require_once('log4php/LoggerManager.php');

Configuration

To set up log4php configuration file (default: ./log4php.xml) see log4php.xml example and log4php.dtd in test/ directory.

Usage

Here is an example on how to use in your php code.
For more examples see test/ directory.
Take also a look at original log4j (documentation).

<?php
require_once('log4php/LoggerManager.php');

class Foo {

    var $logger;
    
    function Foo()
    {
        // create or get a logger instance
        $this->logger =& LoggerManager::getLogger('foo'); 
    }
    
    function doBar()
    {
        // debug
        $this->logger->debug('Foo::doBar()', $this);
    }

}

function Bar()
{
    $logger =& LoggerManager::getLogger('bar');
    $logger->debug('Bar()');
}
?>

Author: Marco Vassura