Update: You can find KLogger on github.
Project Update: See the end of this post for details about KLogger’s current status
KLogger is a simple-to-use PHP text file logging class. It was made to have basic logging functionality, be lightweight, and be safe to use (permissions-wise). The reason for its creation is two-fold: I needed a simple logging class with priority hierarchies ( Debug, Info, Warn, etc .. ), and I couldn’t find it on the internet.
For small web applications or development sites, the use of logging libraries isn’t necessary. All you need is something like KLogger, a simple logging class.
KLogger supports:
- Safe logging (no PHP errors due to permissions)
- Smart file management (closing up resources)
- Priority heirarchies (OFF, DEBUG, INFO, WARN, ERROR, and FATAL)
Basic usage would look like this:
require_once 'KLogger.php'; ... $log = new KLogger ( "log.txt" , KLogger::DEBUG ); // Do database work that throws an exception $log->LogError("An exception was thrown in ThisFunction()"); // Print out some information $log->LogInfo("Internal Query Time: $time_ms milliseconds"); // Print out the value of some variables $log->LogDebug("User Count: $User_Count");
Using KLogger will eventually generate a log file that looks something like this one, which is the actual output from wpSearch, the Lucene based search plugin for wordpress. Tracking down a couple outstanding bugs became much easier once I started using KLogger.
If you happen to be wondering what that log reader is, it’s KTail, a yet-to-be-released log “tailer” written in C#. It is multithreaded, tabbed, and super-useful for reading log files which get updated frequently. It displays changes to almost instantly. (It has yet to be tested on a gigantic log file, though). It’s a side project that doesn’t get a whole lot of attention.
If you think KLogger is what you need, download it (below), and let me know your thoughts by sending an email to katzgrau@gmail.com or leaving a comment on CodeFury.
Update: The KLogger project has moved to GitHub as of June 22, 2010. The original file download will remain intact below. The GitHub equivalent (a tagged release of version 0.1) is available at github too.
http://codefury.net/wp-content/uploads/2008/07/klogger-1.0.0b.zip
To check out the GitHub project, go to:


Pingback: KLogger: A Simple Logging Class for PHP
Pingback: Processing recordings with PHP « The Tropo Blog
Pingback: Making development in PHP less painful with logging
Pingback: 7 Librerie PHP per Creare Applicazioni Web senza Usare un Framework | PillolHacking.Net