Create a log system

Asked

Viewed 120 times

0

Well the default php log system doesn’t suit me 100%.

I wanted to know if there is any way when a php error occurs, I need to save a log and some values that are in, some variables.

I already know how to create and write the txt file, what I need and how to identify that an error occurred in php?

  • 1

    Have you checked the monolog? https://github.com/Seldaek/monolog

1 answer

1

You can do this by extending the PHP Exception class

Example of use:

<?php

class customException extends Exception
  {
  public function errorMessage()
    {
    //error message
    $errorMsg = 'Erro na linha '.$this->getLine().' do arquivo '.$this->getFile()
    .': <b>'.$this->getMessage().'</b>';
    return $errorMsg;
    }
  }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.