Adding Apache log4php
We add apache/log4php as Composer dependency, and a LOGGER_CONFIG
environment variable to specify the path to log4php configuration.
Logger is then configured in _includes/core.php. Any API component can
simply include this file and get a logging capability ready to use.
Background
Currently, some API code throws exceptions, but this is not handled
efficiently on the API output. As we use straightforward and light
formats (e.g. /pads output could be text or JSON array), advertise
the exception message in the API client reply isn't efficient. Instead,
we offer to log the exception.
How to use it
The methods to log events are named according the level:
trace, debug, info, warn, error, fatal
More information at https://logging.apache.org/log4php/
Environment server configuration
Apache log4php allows to customize any logging feature through a
config.xml file. You can specify the path to this file defining
its path to the LOGGER_CONFIG environment variable.
For example, in nginx, you could add:
fastcgi_param LOGGER_CONFIG /data/wolfplex-api/services/logging/config.xml
If the environment variable isn't specified, any exception or message logged
will be displayed in text in the page output, which will break the JSON format.