PHP Classes

Easy log class: Output or write log messages to files

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 271 All time: 7,686 This week: 115Up
Version License PHP version Categories
easy-log-class 1.0GNU General Publi...5PHP 5, Logging


This class can output or write log messages to files

It will take a log message and stores in a given log file that defaults to log.txt file under the log directory. The class may prepend the current date to the log file name.

The log messages may be outputted also to the current page.

Picture of Ashok kumar  kashyap
  Performance   Level  
Name: Ashok kumar kashyap <contact>
Classes: 4 packages by
Country: India India
Age: 37
All time rank: 2051127 in India India
Week rank: 587 Up47 in India India Up


// include the main log class

include "log.php";

// create a object for log class and pass file name parameter as log filename log.txt and log.txt file create under the logs directory
$log= new Log();

// if pass the second parameter as true, then it create log file as datewise like 17-4-2016__log.txt
//$log= new Log('log.txt',true);
$log->write(__FILE__.' this is the file name where the log class was used '); // write any log message

$log->write(' DIR_PATH '.DIR_PATH); // write any log message
$log->write(' DIR_LOGS'.DIR_LOGS); // write any log message

echo "<br>".DIR_PATH;


  Files folder image Files  
File Role Description
Plain text file log.php Class Class source
Plain text file read-me.txt Doc. Documentation
Plain text file Data Auxiliary data
Plain text file test.php Example Example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,686
This week:115Up