Download logs fails with error 500 and apache does not start

Download logs fails with error 500 and apache does not start or Watchdog killed DR process


Issue:
Trying to download logs from the UI fails with error 500 or error Critical Error Watchdog Killed DR process after not responding for more than 1800 seconds


And apache logs showing permission error in /var/log/apache2/error.log (you will need to run sudo su command to access folder/file)
[Sun Jan 08 06:25:58.075748 2023] [wsgi:error] [pid 27795:tid 140300522448640] [client 127.0.0.1:33668] PermissionError: [Errno 13] Permission denied: '/var/log/cpm/cpm_server.log'

In addition, During server restart apache might not start.
This could also cause the error message Critical Error - Watchdog Killed DR process after not responding for more than 1800 seconds
Note:  This KB is relevant for 4.1 and below, as this was handled in latest 4.2.2 version

Solution:

1. connect to cpm over SSH using cpmuser and your key.
2. run the following command: 
  1. sudo chown -R  www-data:www-data /var/log/cpm
After this log download should work and the apache server will start correctly.