5. Try-Catch try { throw new MyAppException('Boofy'); } catch (Exception $e ) { $msg = json_encode(array( 'message' => $e->getMessage(), '_exception' => array( 'class' => get_class($e), 'message' => $e->getMessage(), 'trace' => .. ), )). "n"; error_log($msg, 3, '/path/to/app_error_log'); } 6. set_exception_handler set_exception_handler(function($e) { $msg = decorate_exception($e); error_log($msg,