Fastest most efficient way to add line to a file

melamoud

Active Member
Licensed User
Longtime User
Hi,
I'm building a log utility that will log my logs with some data with Error/warn/etc debug level and I want it to write the logs to a file as well (not just the system log file) - of course it will be configurable

anyone know whats the fastest way to add a line to a file, the method that will have min impact on my CPU consumption, my memory etc
of course each log is an atomic action so I need the file to be close after it, and flushed etc

what file method / object I should use ?

thanks
 

melamoud

Active Member
Licensed User
Longtime User
thanks,

My app is mainly a service waking up on events, so when do I close the file ?
or I do not realy need to ?

thanks
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
For logs, I use a database table, then you just add one record. When it grows over X amount of records, You prune it. (you can make it self cleaning) That way you always have X amount of log records.
 
Upvote 0
Top