Query on File Wrapping

Our application needs to log trace messages to a file for troubleshooting .

Currently once the file size reaches 10MB , we are creating a new file and copying the last 4KB messages to the new file.But the requirement is to wrap the file i.e to always keep the latest 10MB traces.

> Currently once the file size reaches 10MB , we are creating a new
> file and copying the last 4KB messages to the new file.But the
> requirement is to wrap the file i.e to always keep the latest 10MB
> traces.

There isn't any filesystem call to delete bytes from within the file.
Just create a new file and copy the last 10MB to it. But don't do this
on every write, of course, because copying 10MB isn't cheap.