Try this once
It looks complicated at first, but it isn't.
main.php
require_once('/path/to/log4php/Logger.php');
Logger::configure('log4php.xml');
Class Log
{
private $log;
public function __construct()
{
$this->log = Logger::getLogger(__CLASS__);
}
public function myLog()
{
//this prints your data.
$this->log->info("Hello, this is log here");
}
}
//simply call the function
$log=new Log();
$log->myLog();
log4php.xml
<?xml version="1.0" encoding="UTF-8"?>
<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">
<appender name="fileappender" class="LoggerAppenderFile">
<layout class="LoggerLayoutSimple" />
<param name="file" value="/path/to/log/register-%s.log" />
<!-- <param name="append" value="true" /> -->
</appender>
<logger name="Log">
<appender_ref ref="fileappender" />
</logger>
</log4php:configuration>
Note : Don't forget to give 777 permission to folders :)