Hi,
Is there a way to automatically clean up log files that were created by setting the connection to rotate?
Subscribe to forum
Forum
Automatic cleanup of log files
Page: 1
| Author | Post |
|---|---|
|
Cesar
|
#1 Mon Jul 23, 2007 6:10 pm
|
| Guest | |
|
#2 Mon Jul 23, 2007 7:20 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 134
|
Hello Cesar,
This functionality is currently not built-in, but already on our feature request list. You could also achieve the same functionality with a simple background thread which periodically checks if there are too many log files and then deletes unnecessary logs. We have an example (for Delphi) which does exactly this. If you are interested, I can send you the example snippet via email. |
|
Cesar
|
#3 Mon Jul 23, 2007 8:25 pm
|
| Guest |
Yes, I would be interested in the code snippet. Thanks.
|
|
#4 Mon Jul 23, 2007 9:16 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 134
|
Sent! Please let me know if you have any questions about the example.
|
|
#5 Fri Jan 25, 2008 7:15 pm
|
|
|
Member
Registered: Dec 2007
Posts: 35
Location: Poland
|
Hello,
Can I ask for the cleanup code too? |
|
#6 Mon Jan 28, 2008 3:33 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 134
|
Hello Piotr,
Sure. Since several other people have also asked for this, I will post the unit right here. unit LogCleanup; This unit can be used as follows: type Most of the time the background worker thread is put to sleep and thus does not use any unnecessary resources. In a customizable interval, the background thread wakes up and checks if old log files should be deleted. The filename parameter for TLogCleanupThread specifies the base name for the log files to delete. In the example above, the thread is responsible for deleting files with the mask "c:\Test\log*.sil". Moreover, the example uses the default settings for the delete interval (one hour) as well as the maximum allowed log files (10). |
|
#7 Wed Mar 26, 2008 7:29 am
|
|
|
Member
Registered: Jan 2008
Posts: 10
|
Hi Tobias,
I have just started using this code but found it unnecessary to have a background thread waiting for doing a cleanup. I just extracted the actual cleanup code and execute it at program startup. That's enough for my purpose and reduces the overhead. Since I guess you will be adding this code to the smart inspect libraries, maybe you want to also offer this option. twm |
|
piotr rezmer
|
#8 Wed Mar 26, 2008 7:34 am
|
| Guest |
Hello,
I think that cleanup at startup is not enough for long time running server applications. After months or years of running, it may result in GBs of log files. best regards Piotr Rezmer |
|
#9 Wed Mar 26, 2008 12:43 pm
|
|
|
Member
Registered: Jan 2008
Posts: 10
|
I agree. But many are not writing server apps but programs that get restarted at least once a day. Those might not want to have a background thread running all the time which does nothing. It's just a matter of having a choice. twm |
|
#10 Wed Mar 26, 2008 5:35 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 134
|
Hello all,
I think we will probably integrate the cleanup of old log files directly into the file protocol without using additional threads. On startup and whenever a new log file is created, the file protocol could then automatically delete unwanted/unneeded log files. |
|
#11 Wed Mar 26, 2008 10:23 pm
|
|
|
Administrator
Registered: Sep 2007
Posts: 27
|
Hello,
Just to clarify this: we won't just add threads for new features to the libraries without a way to disable them. Some features like asynchronous logging require independent threads, but this is an optional feature (asynchronous logging is planned for SmartInspect 3.0). Just like twm said, we also believe that having a choice to disable such features is important. _______________ Dennis Gurock, Co-Founder Gurock Software GmbH |
Page: 1