Write to a log file with PHP

After writing custom PHP “log” function several times I finally decided to create a simple Logging PHP class. First call of lwrite method will open log file implicitly and write line to the file. Every other lwrite will use already opened file pointer until closing file with lclose. It is always a good idea to close file when it’s done. This should prevent file from corruption and overhead in closing file is negligible.