-
Thread safe logging to file using Java
In an attempt to create a simple logging class for a Java socket server application I was writing I wanted to make sure that the class captured all log events from the various threads sending messages to it. I didn’t want to have the situation where some messages were lost because the class could not handle the log messages being sent to it. In order to do this I decided to use a Consumer – Producer concept. Thankfully in Java this concept has already been thought of via the use of java.util.concurrent.BlockingQueue. The set of classes available for use with this include DelayQueue PriorityBlockingQueue SynchronousQueue ArrayBlockingQueue LinkedBlockingQueue From various readings…