How to display errors in the production environment?

Asked

Viewed 102 times

0

I’m coming from the groove of this question here.

Is there any way, in the production environment, when any error occurs I warn, that the error occurred and I should look at the log file?

I wanted something like this to appear on the screen when an error occurs: Ocorreu um erro, verifique o arquivo de log do sistema.

Remembering that I come from the above question, so in the case in the production environment I do not display the errors, I just store them in a log file.

  • What is the difference between here and there? It seems to me to be the same problem. There you are asking for ways to receive errors, and logging is just one of those means. I think any answer here would fit there. I’m not seeing enough difference not to vote to close.

  • @Bacco type in case it sends the error to the log file, but does not warn anything on the page. I wish I could write on the screen something more or less like this when an error happens: Ocorreu um erro, verifique o arquivo de log do sistema.

  • This already has in your question, what I did not understand is why open a new one, if it is the same problem as the previous one. Your question does not speak of log. In that same someone could talk about the application send an email, for example. Or even record the information in a DB of your monitoring page, as another example.

  • I asked this question in the comment, then the guy who answered me told me to open a new one because it was too long to answer in the comments

  • It seems to me that the problem is that you accepted too early an answer that does not solve your problem, so you decreased the chance for others to respond. A lot of different answers fit in that question of yours.

  • Um, sorry not long ago I met the Stack overflow, do you think I better edit my question there? How long should I wait you recommend? And you can cancel as I accept?

  • I’ll tell you what, I’m not voting to close, because my vote to close PHP duplicate is instant. Let’s see what the rest of the community can do. If they close this, you cancel the acceptance of that, and wait for more answers (or wait for the author of the supplementary answer with more details). If they leave it open, there it is as it is.

Show 2 more comments

1 answer

2


In PHP you can use the function set_error_handler(), and create your own error handling function:

minha_funcao_trata_erros(){
  //sua lógica
}
set_error_handler("minha_funcao_trata_erros");

In this link you can see the documentation of the function set_error_handler() http://php.net/manual/en/function.set-error-handler.php

Browser other questions tagged

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