multithreading - Logging frameworks and synchronization in multi-threaded apps -


i want use logging framework log4cxx in multi-threaded application.

if output of log file, correct serialization of messages needed. asking myself how (and if) these frameworks correct serialization of output without using sort of synchronization object.

i guess if using synchronization objects (for example access queue log messages), cause changes in behaviour of involved threads, changing behaviour (and bugs...) of whole logged application.

log4cxx indeed synchronized, other log4xxx frameworks. synchronization done in appenders , necessary guarantee content of log entries not mixed together. does not change behavior of threads, threads encounter small performance hit. performance hit small compared performance hit of i/o when logging file.

if still worried performance can consider using asynchronous logging (using asyncappender handles logging in separate thread. using async approach cannot guaranteed messages logged (e.g. if application crashes before logging thread handles message). simple way improve performance reduce amount of logging.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -