Cyber Tech Help Support Forums

Cyber Tech Help Support Forums (https://www.cybertechhelp.com/index.php)
-   Web Development & Graphic Design (https://www.cybertechhelp.com/forumdisplay.php?f=20)
-   -   Log File Generation in PHP (https://www.cybertechhelp.com/showthread.php?t=125051)

crashnet July 18th, 2006 09:40 PM

Log File Generation in PHP
 
I'm drawing a blank here and I'd like a few suggestions if possible. I have a search script that searches through a list of articles stored in a database. What I would like to do is record a users search query and store it in a log file so I can display the last 20-40 searches in an admin panel, meaning i would need to both read and write from this log file.

I know how to read and write from the file, but I anticipate a lot of search queries, hundreds to thousands of them in a given day, and I'd like someway to control the size of the log file without having to manually delete it. Is there a way to automatically delete or purge the log file to make it smaller after 'x' number of searches? Or do you have any other recommendations to do this similar idea?

Thanks for the help!

degsy July 19th, 2006 10:25 AM

It would be best to store this in a database.


There are many ways you could manage the file. You could check the file size. Over a certain size then delete it.
You could count the lines. You could read the first 200 lines then save them to a new log and delete the old.

crashnet July 19th, 2006 05:58 PM

Those are a bunch of great ideas. Thanks Degs. With your mention of storing them in a database, I'm beginning to think that may be a better idea. It would be easier to query the database for one, and easier to manage the table size.

Do you have any suggestions of what else would be beneficial to store in the database along with the search query?

Thanks!

degsy July 19th, 2006 06:23 PM

It would be alot more efficient and alot easier to query it.

It depends on how much info you want.
URL, Date/Time, IP Address, Browser etc.


All times are GMT +1. The time now is 06:13 AM.

Copyright © Cyber Tech Help. All rights reserved. All other trademarks are the property of their respective owners.