Add log using file_put_contents - Magesan

Add log using file_put_contents

Add log using file_put_contents

This line of code can be use anywhere for adding or printing a log, For example in magento you have to add dependencies and all to adding a log and this is what time consuming.

So, here follow the line of code and change the file name which will be created as new log file. And change the printing value which you want to print in log

file_put_contents(BP . '/file_path_where_log_print', print_r($variable, true)."\n", FILE_APPEND);

Example :-
file_put_contents(BP . '/var/log/mylog.log', print_r('Prints any String or Whole Array in log', true)."\n", FILE_APPEND);

2 thoughts on “Add log using file_put_contents

  • I Fashion Styles
    04/12/2021 at 11:46 PM

    A large percentage of of the things you say is astonishingly accurate and it makes me wonder why I hadn’t looked at this with this light before. This article really did turn the light on for me personally as far as this specific issue goes. Nevertheless there is one position I am not too comfy with so while I make an effort to reconcile that with the actual core idea of your position, allow me observe exactly what all the rest of your visitors have to point out.Well done.

    05/12/2021 at 3:10 AM

    Hey there, You’ve done a fantastic job. I抣l certainly digg it and personally recommend to my friends. I’m confident they’ll be benefited from this web site.

Leave a Reply

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

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>