At present the logfile locations for emonSD and emoncms related scripts are typically in two locations:
/var/log/emoncms.log /home/pi/data/emonpiupdate.log /home/pi/data/emoncms-sync.log /home/pi/data/postprocess.log /home/pi/data/emoncms-export.log /home/pi/data/emoncms-import.log ...
The use of /home/pi/data arose from placing /var/log in a tmpfs without any persistance. emonpiupdate.log and several others where written to /home/pi/data for persistance.
The new image build scripts that we are developing use log2ram to persist the logs in /var/log and so it makes sense to move these logs back to a suitable location on /var/log.
The proposal here is to move them to:
including the emoncms.log which is currently in the parent directory /var/log.
At present the log paths for emonpiupdate, sync & postprocess are all hardcoded and /var/log/emoncms.log is specified in settings.php using the full file path.
The proposal is to introduce a new setting called $log_location in settings.php that defines the log parent directory (e.g /var/log/emon). If the setting is not present it will default to /var/log/emon. The current $log_filepath would be depreciated. The actual name of the logfile e.g emoncms.log would be hardcoded but its location would be configurable.
I’ve implemented and tested this approach as part of a emoncms development branch called log_location, the changes can be seen here: https://github.com/emoncms/emoncms/compare/log_location
There are also associated changes to the sync module:
The /var/log/emon folder is autocreated by the emoncms_mqtt and feedwriter services following @pb66’s suggestion https://github.com/emoncms/emoncms/compare/log_location#diff-3ad0e4f84032532b09b41599d1c0eae9R54
If users are not using these services and have not created the /var/log/emon log location emoncms works just fine but no logs will be created, a suitable error message is displayed on the emoncms administration page.
The main issue I can see is that switching to this approach right now will mean that all emoncms logs will move to the /var/log tmpfs partition and so will cease to be persistent on existing images. The main log likely to be of concern is the emonpiupdate.log which should ideally be persisted. This could be solved with a symlink, but the symlink would need to be created at system startup, probably not a big issue.