sergant210 / controlErrorLog

Adds the ability to control the MODX Revo error log and view it in a popup window.
MIT License
13 stars 5 forks source link

Error Log path setting #15

Open IamNeo1 opened 6 years ago

IamNeo1 commented 6 years ago

I'm logging into another path. I use my own snippet to change the settings. It is included in the template header as recommended. The Modx error page remains empty, because the system looks into the default path and expects the default name. I want to change the path and name of the error log. I want to see the custom log in the report window.

Template:

<!DOCTYPE html>[[!own_snippets.error_handling]]
<html lang="de">
    <head>
    ...

Snippet "own_snippets.error_handling":

<?php
$context =  strtolower( $modx->context->key );
$user = $modx->getUser();
$user_name = $user->get( 'username' );
$error_log_filepath = 'path_to_folder/var/log/php/';
$error_log_filename = 'modx_' . $context . '_' . $user_name. '_error_log.log';

$modx->setDebug( E_ALL & ~E_NOTICE );
$modx->setLogLevel( modX::LOG_LEVEL_INFO );

$target = array(
    'target' => 'FILE',
    'options' => array(
        'filepath' => $error_log_filepath,
        'filename' => $error_log_filename ),
);

$modx->setLogTarget( $target );

$modx->log(xPDO::LOG_LEVEL_ERROR, 'Error Message', $target);
sergant210 commented 6 years ago

Mission impossible.