Creating a circular log for app
I know how to redirect output from NSLog into a file, so now I'm trying to figure out how to write to that file while it is below a certain size, like say 100 KB. Once the file gets to be >100k, it is deleted and a new file is created in its place. I tried doing this:
while ([fileAttributes fileSize] < '10')
{
freopen(filepath, "a+", stderr);
}
But all it does is basically cause the app to freeze- it become stuck in this loop, and does not load anything. Does anyone have any suggestions as to how I should do this? Do I need to use threading?
|