I'm trying to install log4php in a very simple site (trying to learn how it works). Apache is installed in /etc/ and vhost is defined as:
DocumentRoot "/home/fferri/workspace/site-tutorial/www" ServerName tutorial.localhost php_value auto_prepend_file "/home/fferri/workspace/site-tutorial/www/ConfigureSite.php" My site is at /home/fferri/workspace/site-tutorial/www/ and log4php folder is at /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/
Then, I define
define('LOG4PHP_DIR', "/home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/");
into ConfigureSite.php
And, into another file, I try to init log4php:
include(LOG4PHP_DIR."/Logger.php");
$log = Logger::getLogger("main");
$log->info("foo");
$log->warn("bar");
The error is always the same:
Fatal error: Class 'Logger' not found in /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerRoot.php on line 37
It's worth to say that LoggerRoot.php and Logger.php are in the same folder. I think I have a problem of paths because my server and my site aren't in the same folder, but I need some hint
Adding the complete stack trace of error:
[22-May-2012 11:34:38] PHP Fatal error: Class 'Logger' not found in /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerRoot.php on line 36
[22-May-2012 11:34:38] PHP Stack trace:
[22-May-2012 11:34:38] PHP 1. {main}() /home/fferri/workspace/site-tutorial/www/index.php:0
[22-May-2012 11:34:38] PHP 2. require_once() /home/fferri/workspace/site-tutorial/www/index.php:12
[22-May-2012 11:34:38] PHP 3. require_once() /home/fferri/workspace/site-tutorial/www/greet_at_opening.php:11
[22-May-2012 11:34:38] PHP 4. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/Logger.php:24
[22-May-2012 11:34:38] PHP 5. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerCategory.php:27
[22-May-2012 11:34:38] PHP 6. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/spi/LoggerLoggingEvent.php:28
[22-May-2012 11:34:38] PHP 7. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerManager.php:29
[22-May-2012 11:34:38] PHP 8. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerHierarchy.php:28
So, first, Logger is found but on loading LoggerHierarchy, Logger isn't. Why????
SOLVED: The error is to use log4php-0.9 and php5 together. Downloading the library located in apache web (2.1), the problem is solved.
Thanks!
The error is to use log4php-0.9 and php5 together. Downloading the library located in apache web (2.1), the problem is solved.