Often for my work I am always having to add logging to most of my scripts so I had to create a simple plug and play script that will simply things to do this for me. This script below is rather clean and easy to handle your logging needs. The class also handles timestamps when submitting data to write to the logfile, and the logfile itself extends the actual date, so you get a new log file each day. Very clean and easy to manage!

Often the idea is to add the above coding to a loggerclass.php script or something similar, and use <?php include "loggerclass.php" ?> at the top of your scripts to include the logger class into any of your scripts. You can also just copy paste this to your current script without using an include. A few things to note:

-You don’t need to define the log file name, if you don’t, the name will be “Log_DATE” by default.
-There are two functions that you can use after the logger is defined, which is write to logfile, and truncate the logfile. The file is opened when you call the class and closed when the php script is complete, so you don’t need to handle this!
-If the logfile exists, it will append to the bottom of the logfile, you do not need to worry about it erasing automatically!
-If you are getting permission issues, chmod the directory where the logs are kept to 0777!

So now, if you wanted to use the logger class, an example of using it would be:

This would create a logfile named “MyLog_Date” if it doesn’t exist, and add the message “This is a test message!” to it, with the timestamp. It would look something like this in If you do want to clear the logfile for some reason, you can do this with logClear(), and it will truncate the logfile for you! So the resulting output in the logfile, which would be named “MyLog_09-22-2010″ would be: “09-22-2010 @ 15:49:55 – This is a test message!”… Simple, right?

This should handle your logging needs, and keeps your coding short and clean! One line to open and start logging, and one line per message, which includes the timestamp automatically, nice!

It’s a pity you don’t have a donate button! I’d most certainly donate
to this excellent blog! I guess for now i’ll settle for book-marking and addingg
your RSS feed to my Google account. I look forward to new updates and will shsre this site with my Facebook group.
Chat soon!

Thanks for the marvelous posting! I truly enjoyed reading it, you could be a great author.
I will make sure to bookmark your blog and will often come back from now
on. I want to encourage you continue your great work, have a nice day!

The more popular the page with the links, the more inevitable
a thief will edit it, removing the links and any probability
of gaining. The IQ test is the best known demonstration of
norm-referenced assessment. If it doesn’t feel completely
secure, use bobby pins to add it to hair.

I am really impressed with your writing skills as well as with
the layout on your blog. Is this a paid theme or did you modify
it yourself? Anyway keep up the nice quality writing, it is rare to see a great blog like this one these days.

It is not always about following a recipe letter for letter.
3 cubic feet of interior cooking space and features convection
heating on the top and bottom. You initial need to understand how every single of them works and appear into the rewards and drawbacks of every one of these
appliances.

Have you ever thought about publishing an ebook or guest authoring on other sites?

I have a blog based upon on the same ideas
you discuss and would love to have you share some stories/information. I know my visitors
would enjoy your work. If you are even remotely interested, feel free to send me an e mail.

For example, you may write several articles for Associated Content that are related to each
other. Search engines are far more ‘intelligent’ today and effective SEO requires actual meaningful content pages, social networking, articles submissions,
and a focused marketing effort. SEO and web developer professionals vary on the prescribed keyword density,
usually ranging from a one to three percent density rate.

Hi would you mind stating which blog platform you’re working with?
I’m going to start my own blog soon but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your layout seems different then most blogs
and I’m looking for something completely unique.
P.S Sorry for getting off-topic but I had to ask!

Рretty nice pοst. I ϳust stumbled upon your ѡeblog ɑnd wanted
to say that I have really enjoyed surfing around your blog posts.
Afteг all I’ll be subscriƅing to your feed and I hope you write again soon!

Greetings I am so glad I found your weblog, I really
found you by accident, while I was browsing on Google for
something else, Anyhow I am here now and would just like
to say thanks a lot for a remarkable post and a all round interesting blog
(I also love the theme/design), I don’t have time to read through it all at the moment but I have saved
it and also added in your RSS feeds, so when I have time
I will be back to read a lot more, Please do keep up the fantastic work.

I believe that is among the most significant info for me.
And i’m glad studying your article. However should statement on few common issues,
The website style is perfect, the articles
is in point of fact great : D. Good job, cheers

It’s a shame you don’t have a donate button! I’d without a doubt donate to
this outstanding blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account.
I look forward to brand new updates and will talk about this site with my Facebook group.
Talk soon!

For a excellent instance, check out this YouTuber providing a assessment
of the food at Five Guys Notice how his character and message tie with each
other to craft a youtube video Marketing bangla tutorial that you appreciate watching.