Log4PHP is an open source project that provides a versatile logging framework for PHP. Log4PHP is part of the Apache Logging Services project and it works similarly to other Apache Logging Services sub projects, such as Log4J and Log4Net.

I have just completed to develop the first two topics of my Log4PHP Basics course. You can find its community version available for free personal usage at www.abelski.org. The professional version is available at www.abelski.com. The slides of the first two topics the community version includes are available for free personal usage at the following two URL addresses:

The following video clip shows how to download the Log4PHP. Once you download you just need to make the files available for your project.

The following video clip explains a simple code sample for using the Log4PHP framework. This code sample include two files.

The PHP source code that uses the Log4PHP open source framework.



class Something
    private $log;

    public function __construct()
        $this->log = Logger::getLogger(__CLASS__);

    public function run()
        $this->log->info("simple informative message");
        	$sum += $i;

$ob = new Something();

The XML file that includes the configuration setting for Log4PHP.

<?xml version="1.0" encoding="UTF-8"?>
<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">
    <appender name="fileappender" class="LoggerAppenderFile">
                <layout class="LoggerLayoutTTCC" />
        		<param name="file" value="project_logs.log" />
    <logger name="Something">
        <appender_ref ref="fileappender" />

Leave a Reply

Your email address will not be published. Required fields are marked *