This logger is advanced library, which dumps PHP Application logs to files in production environment.
The main purpose is to ensure the logger is very fast and can be used in production environment. Multiple PHP execution threads log to consecutive files at the same time, to avoid synchronization and locking problems.
There is no need to do any additional setup. Just pure PHP (no mysql even!) and some simple API calls.
WhyLogging in simple application, which is working for one user on a development server is extremely easy:
just open a file, write to it, close (PHP: fopen(), fwrite(), fclose) or even simply file_put_contents()... then open it in any text viewer, and its done – you’ve got the log. No library, nor framework is really needed.
However, in real-time, multi-user, multi-script production environment, this won’t work – simply because there are tens of scripts executing at the same time in different threads or even processes:
This is where PHP Log2Files Advanced Logger fits best… Find out more on Documentation site
Features – the simplicity
- simple API – only two function calls needed to start logging: “open log with some configuration” and then “write to log”
- no additional dependencies (no PEAR , no frameworks), just one PHP file with one class to include in your script
- can be used with almost anything else, easily includable into any other library, framework or existing application
Features – two modes
- simple mode: the textual form – doesn’t need any special parsing
- advanced mode: the BJSON form – stores all data with binary format which is very simple to parse and traverse. This can be used by advanced stats and monitoring tools
Features – performance
- minimal impact to the script timing,
- no SQL , no databases, just PHP and filesystem,
- aware of multi-threading, multiple calls from same web-client at the time, multiple scripts running at a time with very various duration (one in 10ms, while the other in 10secs),
- very little thread/process switching and synchronization, allow OS caches (no flushes etc.),
- so timing-cheap, that log-levels definition is not really needed (simply log all what may be needed),
- dedicated for production environment (megabytes of log in an hour, tens of scripts executing at a time),
Features – other
- dedicated API for handling arrays and maps,
- pre-made implementation for storage of: sessions, cookies, get&post, time of whole script execution,
- easy to transport storage form (copy, delete, etc.): no thousands of files,
- full source code included,