Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log_errors and error_log in php for php.ini

Tags:

php

error-log

ini

I'm troing to change settings in php.ini throu php. My problem is that when there is an error, its not put in to the file error_log.txt, so what am I doing wrong?

This is my code:

// Settings for php.ini
ini_set("session.cookie_httponly", 1);
ini_set("session.cookie_secure", 1);
ini_set('display_errors', 'off');
error_reporting(0);

// errormeddelanden loggas i logs/errorlog.txt 
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/logs/error_log.txt');
like image 616
Sanna Bergström Avatar asked Oct 23 '25 19:10

Sanna Bergström


1 Answers

You can use the function error_log().

A simple example from here would be like

ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );

Then check the log file .you cold see like

tail -f /tmp/php-error.log
like image 63
Avinash Babu Avatar answered Oct 26 '25 08:10

Avinash Babu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!