HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Several questions about how to print logs in both application and plugin.

KunKun New

I found myself struggling at printing log while developing the code.

I have set below to true

  $Configuration['Garden']['Errors']['LogEnabled']  = TRUE;
  $Configuration['Garden']['Errors']['LogFile']  = 'log/error_log';

However, I examine both the vanilla and vanilla-docker folders and can't find the log file. Anyone know where does the error_log file locate? Or maybe I did something wrong?

----

AFAIK, Logger::debug() can not be used in plugin. May I know what is the recommended way to print log in the plugin?

Appreciate any information. Thanks.

Answers

  • Options
    pioc34pioc34 Pézenas ✭✭
    $Configuration['Garden']['Errors']['LogEnabled'] = true;
    $Configuration['Garden']['Errors']['LogFile'] = 'vanilla.log';
    


    i put this and log file is in the vanilla root folder

  • Options

    Thanks, @pioc34 ! As you pointed out, I can see the log printed in the vanilla.log file. I appreciate it very much!!

    With regards to the Plugins, do you have any idea of how to print logs or show debug message in Plugin while the application is running? I tried to utilise "errorLog()", which is working in the application, but not working in Plugin. I can't see any log printing out.

    Any direction or hint would be really appreciated. Thanks!

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Welcome new Vanilla-developer! 😃


    Not sure about the problems with the Logger class, but I would use the helper function logMessage as it is described here: https://open.vanillaforums.com/discussion/26786/tutorial-how-to-enable-a-debug-log-and-collect-debugging-information

    logMessage(__FILE__, __LINE__, get_class($this), __METHOD__, 'YEAH', 'Whatever');

    This is the docblock describing the parameters:

    if (!function_exists('logMessage')) {
       /**
        * Logs errors to a file. This function does not throw errors because it is
        * a last-ditch effort after errors have already been rendered.
        *
        * @param string $file The file to save the error log in.
        * @param int $line The line number that encountered the error.
        * @param string $object The name of the object that encountered the error.
        * @param string $method The name of the method that encountered the error.
        * @param string $message The error message.
        * @param string $code Any additional information that could be useful to debuggers.
        */
       function logMessage($file, $line, $object, $method, $message, $code = '') {
    


Sign In or Register to comment.