How to do error logging in plugin?

edited February 2011 in Vanilla 2.0 - 2.8
Can anyone point me in the right direction for writing to vanilla's error log when there is an error in a plugin?

Comments

  • SS ✭✭
    edited February 2011
    /conf/config.php
    $Configuration['Garden']['Errors']['LogEnabled'] = TRUE; $Configuration['Garden']['Errors']['LogFile'] = 'logs/error-log'; $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
  • Yep that should set it up. How does one go about getting content into it.
    if it were java I would do...
    Logger logger = Logger.getLogger("package.classname");

    if(error condition){
    logger.error("Descriptive error text here to track down problem.");
    }
  • You want to log errors from your plugin into the logs/error-log textfile
    Good question. Maybe it's in the /docs how to do that, otherwise it should be in there (after we've figured it out how it works :-) )

    There was an error rendering this rich post.

  • edited February 2011
    You want to log errors from your plugin into the logs/error-log textfile
    Good question. Maybe it's in the /docs how to do that, otherwise it should be in there (after we've figured it out how it works :-) )
    @Todd I see you're working on documentation
  • @Lincon Could you provide any guidance/best practices?
  • LincLinc Admin
    edited March 2011
    I'm not entirely sure, but I think what you want is:

    throw new Exception($Msg, $Code);

    $Code is optional and would be something like '404' if it's a page not found (and would redirect to that route accordingly), and the message would be what gets logged. I think? Have never looked at the error log, honestly, just shooting blindly based on the code I've seen.
  • Thanks. I'll try playing around with it and see what happens.
Sign In or Register to comment.