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: Streaming wstring into log4cxx::StringBuffer
Date Tue, 12 Apr 2005 15:08:58 GMT
This code will be log4cxx 0.9.7 specific and will not work with the CVS 
HEAD or the forthcoming log4cxx 0.9.8 as StringBuffer is going away and 
log4cxx will be able handle both wchar_t* and char* requests.  If you 
want to stick with 0.9.7 and the form that you have, you need to write 
an insertion operator that converts the wide string to the current 
char* encoding and adds it to the StringBuffer, something like:

log4cxx::StringBuffer& operator<<(log4cxx::StringBuffer& oss, const 
wchar_t* str) {
      //   would need to call wcstombs or similar and insert into 
StringBuffer
}



With the CVS_HEAD

LOG4CXX_INFO(logger, std::wstring(L"BufferReader::Readstring, data :") 
+ v);






On Apr 12, 2005, at 4:22 AM, Staffan Vilcans wrote:

> I'm using log4cxx 0.9.7 and I have read a wstring into v and want to 
> output it to the log. I do like:
> ::log4cxx::StringBuffer oss;
> oss << "BufferReader::Readstring, data : " << v.c_str();
>
> However in the output I get
> 18845 [3209966400] INFO  whine  - BufferReader::ReadString, data : 
> 0x81f89cc
>
> i.e. I get the pointer and not the string like I would hope. I have 
> tried a few other methods, but with no luck.
> How should I do to output a wstring?
>
> -- 
> Cell: +46 737 282 486
> Phone: +46 8 442 75 94 (ext 242)
> Fax: +46 8 24 05 08
> www.jadestone.se
> Björns Trädgårdsgränd 1, 116 21 Stockholm, Sweden
>


Mime
View raw message