You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Staffan Vilcans <st...@jadestone.se> on 2005/04/12 11:22:28 UTC

Streaming wstring into log4cxx::StringBuffer

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


ROling file appender not working?

Posted by br...@sbox.tugraz.at.
I tried now the last version which worked under windows (31.3.)

It seems that the roling file appender is not working.
Is there a way around this?
Or at least a way to specify a maximum file size in a normal appender?

best regards
ML





Re: CVC head not working under Windows?

Posted by Curt Arnold <ca...@apache.org>.
Unfortunately yes, see 
http://marc.theaimsgroup.com/?l=log4cxx-dev&m=111233291509541&w=2.

The apr_xlate_open function has problems loading the current default 
code page on Windows, it creates and encoding name like "Cp1252" when 
the encoding module is actually named "windows-1252".  I've also 
discovered several other annoying habits of apr-iconv (an iconv 
implementation which is used by apr_xlate on platforms without a 
"native" iconv) which have convinced me to rewrite charset transcoding 
code so it does not depend on apr_xlate on Windows.

Until I have a chance to rework that code, you may want to pull a 
snapshot from before 31 March (can't find my CVS book at the moment to 
give you the syntax).

On building a release version, use

ant -Ddebug=false


CVC head not working under Windows?

Posted by br...@sbox.tugraz.at.
I tried the ant build of the latest CVS head.
The build worked till dthe test part where I got an exception.

Then I used the DLL in my test appl, and found that an exception is thrown
in the folowing code fragment:

CharsetDecoder::CharsetDecoder(const char* frompage) {
#if LOG4CXX_LOGCHAR_IS_WCHAR
  const char* topage = "WCHAR_T";
#endif
#if LOG4CXX_LOGCHAR_IS_UTF8
  const char* topage = "UTF-8";
#endif
  apr_status_t stat = apr_xlate_open((apr_xlate_t**) &convset,
     topage,
     frompage,
     (apr_pool_t*) pool.getAPRPool());
  if (stat != APR_SUCCESS) {
    throw IllegalArgumentException(topage); // <== throws exception
  }
}

So what does that mean?
Am I doing something wrong, is something missing, ....???

And another question: Is there also a way to build a release version of 
the DLL ?

Best regards
ML




Re: Streaming wstring into log4cxx::StringBuffer

Posted by Curt Arnold <ca...@apache.org>.
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
>