Use array_slice to make the code more efficient
Service is unable to create the directories. Make the failed directories with app_defaults when run from command line.
php /var/www/fusionpbx/core/upgrade/upgrade.php
chown -R www-data:www-data /var/log/freeswitch/xml_cdr