We have a message processing system where low latency is critical. Recently, I found that while we keep a high rate through our system we are seeing some "outliers." (Messages that take much longer then they should) When we removed logging our systems show none of these outliers. 

Right now our logging is basically just a wrapped ostream with some logging-level functionality similar to log4j (debug, fatal, debug, etc). 

I was wondering, what do others do to manage logging performance, specifically in message processing activities? How do you manage these I/O bound activities? Do you stripe it out? Do you move to databases instead?

Any advice for optimizing logging is appreciated.

Note: I recognize that there might be other problems with our system that causes the outliers, but for the sake of this question I am only interested in logging optimizations, thanks. 

Also: Logging is mandatory for our system.