I urge you to reconsider your design. It would be much simpler if you had a designated process whose sole job is to write to the log file - a logger in the style of syslogd.
When one of the worker threads/procs wants to write to the log file then it sends a request to the logger. There you have a number of mechanisms you could use for inter-process communications, sockets, message queues, or even a named pipe, provided the record is not too large.