PHP Log to File: Log messages to given file

Recommend this page to a friend!
  Info   View files Documentation   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-03-04 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 100 All time: 9,484 This week: 234Up
Version License PHP version Categories
phplog 1.0.1Custom (specified...5PHP 5, Files and Folders, Logging
Description Author

This class can log messages to given files.

It provides static functions to log messages either to the PHP error log or to a specific file in a given directory.

It may create the directory to store the log files, if the directory does not exist.

The class can check the values of certain constants to get the log file name, the destination directory for the log files or the text that may be used to divide the log messages.

Picture of Daniel Riera
  Performance   Level  
Name: Daniel Riera <contact>
Classes: 1 package by
Country: Spain Spain
Age: ???
All time rank: 4316118 in Spain Spain
Week rank: 588 Up20 in Spain Spain Up




Custom static class for register messages with simple methods.


With Composer

composer require danielriera/phplog


LOG_DEFAULT_FILE Default file if $type is not defined, default: 'user'

LOG_FOLDER Folder on put files, default: '/'

LOG_DIVIDE_ELEMENT If defined divide files by $element, default: No defined


LOG::add(msg, element, type)

  • msg: String | Array | Object to register.
  • element: String or Integer id, default: false.
  • type: Type of log register, default: ``LOG_DEFAULT_FILE`` (user)


LOG::add("Test Line");
LOG::add("Test User Line", 524);
LOG::add("Other User Line", 524);
LOG::add("Order Test Line", 'WEB581657816', 'order');
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetest (1 file)
Accessible without login Plain text file Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file class.log.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file index.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,484
This week:234Up

For more information send a message to info at phpclasses dot org.