Reading list Switch to dark mode

    Debug data in Opencart

    Updated 1 July 2016

    As Opencart already provides the library file(log.php) for debugging data so it’s very easy to debug data in any controller or model file of your module. For debugging of data, you can write the code below in any of your files.

     

    $this->log->write($data); // $data variable contains the data to be debug

     

    The information of debug data will be visible at admin’s panel at System-> Tools-> Error Logs. You can also view the file in which all debug data is stored at location system-> storage-> logs-> error.log of Opencart version 2.1.x.x and 2.2.x.x.

    You can also create a file of yours for debugging the data. For that, you have to pass the file name in the constructor of log library. Please see the code below.

    Searching for an experienced
    Opencart Company ?
    Find out More

     

    $logger = new Log('file_name.log'); //just passed the file name as file_name.log
    $logger->write($data); // again $data contains the data the need to be log

     

    By executing the above code, a new file will be created named file_name.log in the system-> storage-> logs-> file_name.log and all the saved data will be found in this file.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home