PHPLog is a Logging Framework written in PHP which has a lot of its ideas from Apache Log4PHP.
It extends on the base functionality that most other logging frameworks provide. Including:
- A logging hierarchy in which we can have namespaced loggers (i.e a logger can have a parent logger instance)
- Logging events are propagated down the hierarchy until they are handled (This can be turned off at any point in the chain.)
- An advanced pattern parser which is used to format Log events as strings.
- Specific object type rendering, A Renderer can be provided for objects, primatives and the null type which convert that specific object type into a string. We can also concatinate output when there is more than one renderer that matches a specific object type, i.e Different renderers based on the inheritance of an object.
- Filters & Thresholds can be applied to the logger so determine if the logging event is handled by that particular logger or pushed down the chain.
- Extra variables can be pushed to a Log Event at 3 different scope levels.
- Global - The extras added to the global scope will be passed to all logging events in the current logging hierarchy.
- Logger - The extras added to the logger scope will be passed to all logging events in the current logger instance.
- Log Event - The extras added to the log event scope will be added to that single log event.
- Multiple writers can be assigned to a single logger instance.
Initializing a new logging instance is done by using the '''php $logger = Logger::getLogger('LOGGER_NAME'); ''' method. This will return a new logger instance with no other configuration attached.
You can add writers by either providing an array of initial configuration to the getLogger function or using the add* methods on the Logger instance itself.