API seems to fail when attempting to use component log files

Forum for questions and support relating to the 1.30.x releases only.
Locked
kennbr34
Posts: 48
Joined: Sat Jan 14, 2017 6:43 pm

API seems to fail when attempting to use component log files

Post by kennbr34 »

I was trying to setup ZoneMinder to send logs to /var/log/zm/ in individual log files so that I could track it outside of syslog. Anyway, I noticed that when I enabled the "component logs" option in the Logging options of the web console, that the API would no longer authenticate properly. zmNinja would no longer work, and when I went to myserver/zm/api/ there was just a CakePHP error page. I checked my apache error logs with tail after loading the page, and found this.

Code: Select all

PHP Warning:  file_put_contents(/var/log/zmerror.log) [<a href='http://php.net/function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in /usr/share/zoneminder/www/api/lib/Cake/Log/Engine/FileLog.php on line 142
I'm not sure why it was doing this, as the /var/log/zm/ directory had proper permissions and ownership, and all the logging components were writing successfully.

At any rate, I decided I didn't need the logging to /var/log/zm/ afterall, but thought I should still bring this to light. Once I changed it back to default logging, the API works fine again.
User avatar
iconnor
Posts: 2896
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: API seems to fail when attempting to use component log files

Post by iconnor »

Which distro and how was ZoneMinder built? In ubuntu, cake should be automatically configured to put it's log files in /var/log/zm/cake_error.log.

I see that your cake is trying to create /var/log/zmerror.log which it won't have the permissions to do. You can edit /usr/share/zoneminder/www/api/app/Config/bootstrap.php

/**
* Configures default file logging options
*/
App::uses('CakeLog', 'Log');
CakeLog::config('debug', array(
'engine' => 'File',
'types' => array('notice', 'info', 'debug'),
'file' => 'cake_debug',
'path' => '/var/log/zm/'
));
CakeLog::config('error', array(
'engine' => 'File',
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'cake_error',
'path' => '/var/log/zm/'
));
CakeLog::config('custom_path', array(
'engine' => 'File',
'path' => '/var/log/zm/'
));
Locked