Most likely the problem is that you have multiple threads trying to append to the file at the same time. Nothing good can come of this.
My suggestion would be to have a logging thread and a queue. When a thread wants to write to the log, it just puts the message on the logging queue. The logging thread reads from the queue and writes to the log file.
Of course, you'll have to add some synchronization to the queue so that it doesn't get corrupted by concurrent requests, or find a concurrent queue that already handles that synchronization for you.