Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Log reports

Status
Not open for further replies.

eelisdotnet

Programmer
Oct 3, 2004
10
FI
Hi

I'm trying to figure out the best practice to manage log reports generated by my application.
The application generates a log file for each process, and those files are all saved under a specific directory. The log file name is combined of the process name and the date-time of the creation (process.20060221-1605.log).
The idea is to have a class that manage all the log files. There should be a limit for the amount of log files in the folder so that every time a new log is written, it has to check that there are not too many files and delete the oldest in case of too many.

Again, I'm looking for the best practice to implement it if one can share his/her ideas.

Thanks in advance!
 
I would make my class count the number of files that are in the directory (you will find all you need in system.io). And then delete the oldest on if it has more then a certain amount of files in it of a certain type. And you do this when you make a new log file.

Christiaan Baes
Belgium

"My new site" - Me
 
Thanks Christiaan!

I thought about this class implementation and actually started to work on it already. I was just wondering whether there is a better way, such as using XML file to list and manage the reports..
 
Depends on how much reports you have and how frequent you will want to consult the files.

Christiaan Baes
Belgium

"My new site" - Me
 
Normally there is one report per day, but occasionally it could be several per day.
The limit is set by the user with a default of 30 (approx. one month).
Size of each report varies to a maximum of 2-3 KB.
 
No need to use XML for this -- just some ArrayLists will be all you'll need to hold the files.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top