logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: simple stringstream appender
Date Wed, 18 Aug 2010 03:08:13 GMT
STL streams maintain an internal state and would not be safe to use in an appender unless you
used external synchronization and precomposed the message so that it was done as one operation.

For example, if you did something like:

os << "Hello" << "World";

if os was visible from another thread, you could have another thread inject something between
"Hello" and "World".

We do however offer a STL stream-like interface for logging in log4cxx/stream.h.  The current
implementation does attempt to mimic as far as possible the semantics of STL streams which
unfortunately can add a substantial performance penalty for features (like inserting format
specifiers) that you may not use.  If you really want to dive into it, search the archives
for logstream.

For an example of logstream usage, see src/examples/cpp/stream.cpp.

On Aug 16, 2010, at 2:01 AM, andrejvanderzee wrote:

> Hi,
> I need an appended that writes to a stringstream. I want to be able to get
> the complete log after my CGI application is finished. Then I want to be
> able to access the complete log. How can I do this?
> I guess I could use a FileAppender and write to a temporary file and after
> my CGI application finishes read the log from the file. But, I prefer a
> stringstream solution.
> Thank you,
> Andrej
> -- 
> View this message in context: http://old.nabble.com/simple-stringstream-appender-tp29447240p29447240.html
> Sent from the Log4cxx - Users mailing list archive at Nabble.com.

View raw message