Moving the MODX error log to a different location
By default, the MODX error log is located in the cache folder. This sometimes this is problematic, when you delete the cache folder for deployments or because of other issues. So we recommend to move the MODX error log to a different folder so it persists and won‘t get deleted.
Since MODX 2.7.0 you can use 2 new system settings for this! There is
error_log_filepath to specify any (absolute) path on the server. This could be any path like
/var/log/ or something like
Another new setting is
error_log_filename which allows the rename the log file itself (by default it‘s
error.log). One recommendation would be to rename it to
modx.log which makes it easier to identify when stored at a shared location with other log files.
A note on multi-context projects which use routing extras: You might experience that MODX keeps writing some log entries to the old log location. This issue has been fixed recently by us and will be available with the next MODX 2.7.1 release.
When working with log files you should always pay attention to their file size. This can become an issue with limited disk space is shared environments for example. One solution is logrotate, which can be used to regularly rename your files (based on time or filesize) and to only keep a specified amount of files. A typical logrotate config could look like this: