phplaravelhierarchylog4php

php, laravel, log4php: Class 'Apache\Log4php\Hierarchy' not found error


I'm new to php and i'm using log4php with laravel. My project structure is

->Root
        ->Laravel
                ->app
                    ->folderx
                            ->abc.php
        ->otherfolders
        .
        .
        ->vendor
        ->composer.json (contains log4php and laravel)
        ->logconfig.xml

I'm trying to initialize the logger from inside abc.php,

Logger::configure('../../../logconfig.xml');

but it gives the error message

Class 'Apache\Log4php\Hierarchy' not found

I verified that the class Hierarchy.php exists in the vendor/apache/log4php/src under Root folder. Also, if I open Logger.php and go to the line where Hierarchy in initialized and ctrl+click(in eclipse) on Hierarchy, it takes me to Hierarchy.php.

I'm trying to figure out why php is not able to find that class. Any help/suggestions would be greatly appreciated.

Thanks


Solution

  • That error message shows that your PHP is looking for a namespaced class. Log4PHP has never been released until now with namespaces (up to version 2.3.0), so this is definitely weird.

    If you accidentially use the development branch of the 3.0 version, I must currently suggest not to use it. It barely got any significant commits in the last year, and should be considered work in progress (very slow progress unfortunately).