The Log4PHP Logging Framework PRO

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:
http://www.abelski.com/courses/log4php/introduction.pdf
http://www.abelski.com/courses/log4php/basics.pdf

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.

<?php
include('log4php/Logger.php');

Logger::configure('loggingconfiguration.xml');

class Something
{
    private $log;

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

    public function run()
    {
        $this->log->info("simple informative message");
        $i=1;
        $sum=0;
        while($i<=10)
        {
        	$sum += $i;
        	$this->log->info("i=".$i);
        	$i++;
        }
    }
}

$ob = new Something();
$ob->run();
?>

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" />
    </appender>
    <logger name="Something">
        <appender_ref ref="fileappender" />
    </logger>
</log4php:configuration>

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

NoSQL Databases Courses, Seminars, Consulting, and Development

MongoDB Design Patterns Meetup

The use of MongoDB involves with various cases in which we can overcome performance issues by implementing specific design patterns.

image of woman and database

Record Classes in Java

Learn how to define record classes in Java, and when to use record classes in your code. Stay up to date with the new Java features.

Accessibility | Career | Conferences | Design Patterns | JavaScript | Meetups | PHP | Podcasts | Python | Self Learning

Teaching Methodologies | Fullstack | C++ | C# | CSS | Node.js | Angular | Java | Go | Android | Kotlin | Swift | Academy

Front End Development | Scala | Architectures | Cloud | Big Data | Internet of Things | Kids Learn Programming

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Skip to content Update cookies preferences