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: 272 This week: 1All time: 7,697 This week: 560Up
Version License PHP version Categories
easy-log-class 1.0GNU General Publi...5PHP 5, Logging
Description 

Author

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: 38
All time rank: 2050127 in India India
Week rank: 416 Up25 in India India Up

Example

<?php
// 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;
echo
DIR_LOGS;



?>


Details

This class is create or maintain the log file for your application, where you will create any log message for your application and store in log.txt file under the log directory, you also create the date wise log file with custom name . // create logs folder under the root folder // 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

  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 README.md Data Auxiliary data
Plain text file test.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:272
This week:1
All time:7,697
This week:560Up