Skip to content

Error Log path setting #15

@IamNeo1

Description

@IamNeo1

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions