See http://issues.apache.org/jira/browse/LOGCXX-126

The suggested fix is to modify SystemErrWriter (and in the same way
SystemOutWriter) as follows:

OLD:
====

void SystemErrWriter::write(const LogString& str, Pool& p) {
#if LOG4CXX_HAS_WCHAR_T
    LOG4CXX_ENCODE_WCHAR(msg, str);
    std::wcerr << msg << std::flush;
#else
    LOG4CXX_ENCODE_CHAR(msg, str);
    std::cerr << msg << std::flush;
#endif
}

NEW:
====

void SystemErrWriter::write(const LogString& str, Pool& p) {
    LOG4CXX_ENCODE_CHAR(msg, str);
    std::cerr << msg << std::flush;
}

It is then, at least, assured that log4cxx always only writes on
the narrow streams, never on their wide counterparts. The application
which uses log4cxx must then also *always* write to the narrow
streams, if at all.

A more sophisticated solution would be to make it configurable
whether to use the wide or the narrow streams. This could be
a independant configuration, or be based on LOG4CXX_HAS_WCHAR_T.
There are a couple of files which do direct cout/cerr, which would
need to be adjusted.

Comments and thoughts? :-)

Thanks & best Regards,

        Andreas

Reply via email to