error_log message is truncated when using print_r

Cotten

I'm not experienced in PHP and I'm, using:

error_log("big array:" . print_r($bigArray, true));

to look at what's inside a big array but it looks like the output is cut off before I get to the interesting stuff in the output like so:

...
           [4] => Array
            (
                [id] => 100039235
                [start] => 11:00
                [end] => 19:00
                [punches] => Array
                    (
                        [0] => Array
                            (
                                [id] => 6319
                                [comment] => 

Is this expected? Are there other ways or workarounds to get more of the array logged out?

h2ooooooo

If you check the error INI options in PHP you'll notice there's a log_errors_max_len option:

Set the maximum length of log_errors in bytes. In error_log information about the source is added. The default is 1024 and 0 allows to not apply any maximum length at all. This length is applied to logged errors, displayed errors and also to $php_errormsg.

When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.

Hence, if you want to use error_log to output these huge messages, make sure you change log_errors_max_len to a large number (or 0 for unlimited length).

// Append to the start of your script
ini_set('log_errors_max_len', 0);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

console.log message is truncated

How to log an PHP error_log error message to Apache server error_log?

Error message about username when using plotly r package offline

Error message with aggregate() when using my own function in R

Substring function not working when truncated using mysql

Suppress 'file truncated' messages when using tail

Log/Feedback message when using EL

Truncate output after X lines and print message if and only if output was truncated

R: Time values in some columns are truncated in their seconds part when using read_csv

R crashes when fitting truncated normal distribution

Truncated Logcat Exception Message

Truncated message tweets

error message "undefined" when using Redux?

Runtime error message when using boost::wave

Error 400 when sending a message using python

received error message when using component

Python error message when using import

R print table using message

grep to search error_log and email only when results found?

Influence of number of steps back when using truncated backpropagation through time

tweepy: truncated tweets when using tweet_mode='extended'

String is being truncated when passed in request using jquery ajax post

String or binary data would be truncated when using it in a stored procedure

Tables truncated when using bigquery api (buffer size issue?)

print_r() multidimensional array using PHP while

How does the output of PHP functions work using print_r?

MySql returning only 1 row in page using print_r

I am using a JOptionPane to show error message but when I click ok on the error message it does not close the message

How can I log/print a custom error message when response.raise_for_status() == 404?