From: vvv j. <vv...@ya...> - 2012-05-30 17:08:49
|
Hi log4cplus Devel Team, I got some bug when trying to log Unicode text. The logger could log ASCII text correctly but when I give Unicode text the Logger is not logging any other text also. Is this the same problem as Not able to log unicode character on Linux Platform. - ID: 3446131. I'm using log4cplus in Windows XP with Visual Studio 2008. Working with dynamic library with Debug Unicode support. Please let me know if it is the same problem and still existing. Also let me know if there any option to support Unicode text logging without changing the log4cplus library (1.0.4.1-RC2). Thanks J.Viswanath |
From: Václav Z. <vha...@gm...> - 2012-05-31 09:41:36
|
On 30 May 2012 19:08, vvv jjj wrote: > Hi log4cplus Devel Team, > > I got some bug when trying to log Unicode text. The logger could log ASCII > text correctly but when I give Unicode text the Logger is not logging any > other text also. > > Is this the same problem as Not able to log unicode character on Linux > Platform. - ID: 3446131. > > I'm using log4cplus in Windows XP with Visual Studio 2008. Working with > dynamic library with Debug Unicode support. > > Please let me know if it is the same problem and still existing. Also let me > know if there any option to support Unicode text logging without changing > the log4cplus library (1.0.4.1-RC2). How are you giving Unicode text to log4cplus? Is it part of your C++ source? Then how is your C++ source encoded? What configuration of log4cplus are you using (Release or Release_Unicode)? -- VZ |
From: vvv j. <vv...@ya...> - 2012-05-31 15:46:29
|
Hi log4cplus Devel Team, Thanks Václav Zeman. I gave Unicode text directly in the cpp file. (Ex: CString str = _T("Ω⅓∂₤◊");) The file is saved with unicode support (the default yes button when Unicode file is saved in Visual Studio 2008). The configuration used is Debug Unicode dynamic library. Please let me know if you need any other details. Regards J.Viswanath ________________________________ From: Václav Zeman <vha...@gm...> To: vvv jjj <vv...@ya...> Cc: "log...@li..." <log...@li...> Sent: Thursday, 31 May 2012 3:11 PM Subject: Re: [Log4cplus-devel] Unicode Text Logging On 30 May 2012 19:08, vvv jjj wrote: > Hi log4cplus Devel Team, > > I got some bug when trying to log Unicode text. The logger could log ASCII > text correctly but when I give Unicode text the Logger is not logging any > other text also. > > Is this the same problem as Not able to log unicode character on Linux > Platform. - ID: 3446131. > > I'm using log4cplus in Windows XP with Visual Studio 2008. Working with > dynamic library with Debug Unicode support. > > Please let me know if it is the same problem and still existing. Also let me > know if there any option to support Unicode text logging without changing > the log4cplus library (1.0.4.1-RC2). How are you giving Unicode text to log4cplus? Is it part of your C++ source? Then how is your C++ source encoded? What configuration of log4cplus are you using (Release or Release_Unicode)? -- VZ |
From: Václav Z. <vha...@gm...> - 2012-05-31 17:21:33
Attachments:
signature.asc
|
On 05/31/2012 05:46 PM, vvv jjj wrote: > Hi log4cplus Devel Team, > > Thanks Václav Zeman. > > I gave Unicode text directly in the cpp file. (Ex: CString str = > _T("Ω⅓∂₤◊");) > The file is saved with unicode support (the default yes button when > Unicode file is saved in Visual Studio 2008). The configuration used > is Debug Unicode dynamic library. > > Please let me know if you need any other details. > > Regards > J.Viswanath > > ------------------------------------------------------------------------ > *From:* Václav Zeman <vha...@gm...> > *To:* vvv jjj <vv...@ya...> > *Cc:* "log...@li..." > <log...@li...> > *Sent:* Thursday, 31 May 2012 3:11 PM > *Subject:* Re: [Log4cplus-devel] Unicode Text Logging > > On 30 May 2012 19:08, vvv jjj wrote: > > Hi log4cplus Devel Team, > > > > I got some bug when trying to log Unicode text. The logger could log > ASCII > > text correctly but when I give Unicode text the Logger is not > logging any > > other text also. > > > > Is this the same problem as Not able to log unicode character on Linux > > Platform. - ID: 3446131. > > > > I'm using log4cplus in Windows XP with Visual Studio 2008. Working with > > dynamic library with Debug Unicode support. > > > > Please let me know if it is the same problem and still existing. > Also let me > > know if there any option to support Unicode text logging without > changing > > the log4cplus library (1.0.4.1-RC2). > How are you giving Unicode text to log4cplus? Is it part of your C++ > source? Then how is your C++ source encoded? What configuration of > log4cplus are you using (Release or Release_Unicode)? > > -- > VZ > > I have commented on the bug #3446131. But because your problems are on Windows and not Linux, the solution might be different: Ok, I think I have reproduced your problem with log4cplus 1.0.4.1 release. The problem has two layers: 1. There is the std::locale::global (LOCALE); line that is or is not in your source, where LOCALE is either std::locale ("") or std::locale (). 2. ./configure script flags: NONE, --with-working-locale (and --with-working-c-locale or --with-iconv) This gives us 6 combinations of these two parameters. To test this I have used ftests/fileappender_test with "Entering loop číslo/番:" string to log. Log4cplus was compiled with CPPFLAGS="-DUNICODE=1". (1) no parameters to ./configure std::locale::global: missing The test breaks exactly as you have reported: log4cplus: Just opened file: Test.log log4cplus:WARN RollingFileAppender: MaxFileSize property value is too small. Resetting to 204800. log4cplus:ERROR file is not open: Test.log log4cplus: Destroying appender named [First]. log4cplus: Destroying appender named [First]. (2) no parameters to ./configure std::locale::global(std::locale()); Same result as for (1). (3) no parameters to ./configure std::locale::global(std::locale("")); The logger keeps on logging. ASCII text goes through unmodified, numbers get formatted according to my locale (my environment variable LANG is set to en_US.UTF-8). The testing Unicode characters pass through unmodified as well. I see 4 bytes per character (sizeof(wchar_t) == 4 on Linux platforms). (4) std::locale::global: missing ./configure with --with-working-locale The logging works but the non-ASCII characters are replaced by question marks: 600 [139678217910080] DEBUG test.subtest <loop> - Entering loop ????slo/??????19759 (5) std::locale::global(std::locale()); ./configure with --with-working-locale Same result as for (4). (6) std::locale::global(std::locale("")); ./configure with --with-working-locale The logging works, numbers are formatted according to locale (en_US.UTF-8) and the non-ASCII characters show up as well: 165 [139,711,023,560,512] DEBUG test.subtest <loop> - Entering loop číslo/番:18,467 CONCLUSION The whole matter is unfortunately very complicated. The result depends on your locale settings, on capabilities of your compiler and standard C++ library. It also depends on compile time settings of log4cplus itself. Unless you really (really) have to handle wchar_t strings, then I strongly suggest that you do not compile log4cplus with -DUNICODE switch. Most of Linux distributions these days use UTF-8 as their native encoding and that passes through to the Test.log file unharmed in all cases (that I have tested) whether the --with-working-locale switch is present or not, whether any std::locale::global (LOCALE) line is present or not. Conclusion of the conclusion, I suggest configuring log4cplus on _Linux_ platforms with GCC with the --with-working-locale switch and _without_ -DUNICODE. -- VZ |
From: Václav Z. <vha...@gm...> - 2012-06-01 13:22:30
|
On 31 May 2012 19:21, Václav Zeman wrote: > On 05/31/2012 05:46 PM, vvv jjj wrote: >> Hi log4cplus Devel Team, >> >> Thanks Václav Zeman. >> >> I gave Unicode text directly in the cpp file. (Ex: CString str = >> _T("Ω⅓∂₤◊");) >> The file is saved with unicode support (the default yes button when >> Unicode file is saved in Visual Studio 2008). The configuration used >> is Debug Unicode dynamic library. >>[...] I have reproduced your problem on Windows as well. The problem is Windows problem with its code pages. Even though you are using the Debug_Unicode (or Release_Unicode) configuration, which means that the output stream is std::wfstream, the output file is always using chars (not wchar_ts). If you insist on logging characters outside of your Windows code page, then you are unfortunately (nearly) out of luck for 1.0.4.1. The best way to work around this for 1.0.4.1 would be to derive your own appender from *FileAppender that you use and either (1) override its append() member function to do, either wchar_t -> UTF-8 (or any other translation) on the fly, or, if you can use Visual Studio 2010, (2) imbue the underlying file stream with, e.g., std::codecvt_utf8<tchar, 0x10FFFF, static_cast<std::codecvt_mode>(std::consume_header | std::little_endian)> facet. For trunk and 1.1.x branches you can do (2) using imbue() member function on *FileAppender. -- VZ |
From: vvv j. <vv...@ya...> - 2012-06-01 16:51:48
|
Hi log4cplus Devel Team, Thanks Václav Zeman for the detailed explanation. I understood that the problem is not with log4cplus library but it is the behavior of stream in c++. I will try the deriving the FileAppender and check the output or may be I change the code in log4cplus as I'm using both RollFileAppender and DailyRollFileAppender. Regarding the 2nd options imbue I'm using Visual Studio 2008, so need to check if that options work or not. Thanks again to log4cplus team for giving good support. Regards J.Viswanath ________________________________ From: Václav Zeman <vha...@gm...> To: vvv jjj <vv...@ya...> Cc: log...@li... Sent: Friday, 1 June 2012 6:52 PM Subject: Re: [Log4cplus-devel] Unicode Text Logging On 31 May 2012 19:21, Václav Zeman wrote: > On 05/31/2012 05:46 PM, vvv jjj wrote: >> Hi log4cplus Devel Team, >> >> Thanks Václav Zeman. >> >> I gave Unicode text directly in the cpp file. (Ex: CString str = >> _T("Ω⅓∂₤◊");) >> The file is saved with unicode support (the default yes button when >> Unicode file is saved in Visual Studio 2008). The configuration used >> is Debug Unicode dynamic library. >>[...] I have reproduced your problem on Windows as well. The problem is Windows problem with its code pages. Even though you are using the Debug_Unicode (or Release_Unicode) configuration, which means that the output stream is std::wfstream, the output file is always using chars (not wchar_ts). If you insist on logging characters outside of your Windows code page, then you are unfortunately (nearly) out of luck for 1.0.4.1. The best way to work around this for 1.0.4.1 would be to derive your own appender from *FileAppender that you use and either (1) override its append() member function to do, either wchar_t -> UTF-8 (or any other translation) on the fly, or, if you can use Visual Studio 2010, (2) imbue the underlying file stream with, e.g., std::codecvt_utf8<tchar, 0x10FFFF, static_cast<std::codecvt_mode>(std::consume_header | std::little_endian)> facet. For trunk and 1.1.x branches you can do (2) using imbue() member function on *FileAppender. -- VZ |
From: vvv j. <vv...@ya...> - 2012-06-06 17:30:20
|
Hi log4cplus-devel Team Regarding Unicode support, I impemented a null codeset and imbued to file stream as mentioned in the url (http://forums.codeguru.com/showpost.php?p=1741409&postcount=8) in FileAppender file in FileAppender::open method. Also changed the open mode of stream with binary option enabled in FileAppender file. Please let me know if the above approach has any issues. Thanks J.Viswanath ________________________________ From: vvv jjj <vv...@ya...> To: Václav Zeman <vha...@gm...> Cc: "log...@li..." <log...@li...> Sent: Friday, 1 June 2012 10:21 PM Subject: Re: [Log4cplus-devel] Unicode Text Logging Hi log4cplus Devel Team, Thanks Václav Zeman for the detailed explanation. I understood that the problem is not with log4cplus library but it is the behavior of stream in c++. I will try the deriving the FileAppender and check the output or may be I change the code in log4cplus as I'm using both RollFileAppender and DailyRollFileAppender. Regarding the 2nd options imbue I'm using Visual Studio 2008, so need to check if that options work or not. Thanks again to log4cplus team for giving good support. Regards J.Viswanath ________________________________ From: Václav Zeman <vha...@gm...> To: vvv jjj <vv...@ya...> Cc: log...@li... Sent: Friday, 1 June 2012 6:52 PM Subject: Re: [Log4cplus-devel] Unicode Text Logging On 31 May 2012 19:21, Václav Zeman wrote: > On 05/31/2012 05:46 PM, vvv jjj wrote: >> Hi log4cplus Devel Team, >> >> Thanks Václav Zeman. >> >> I gave Unicode text directly in the cpp file. (Ex: CString str = >> _T("Ω⅓∂₤◊");) >> The file is saved with unicode support (the default yes button when >> Unicode file is saved in Visual Studio 2008). The configuration used >> is Debug Unicode dynamic library. >>[...] I have reproduced your problem on Windows as well. The problem is Windows problem with its code pages. Even though you are using the Debug_Unicode (or Release_Unicode) configuration, which means that the output stream is std::wfstream, the output file is always using chars (not wchar_ts). If you insist on logging characters outside of your Windows code page, then you are unfortunately (nearly) out of luck for 1.0.4.1. The best way to work around this for 1.0.4.1 would be to derive your own appender from *FileAppender that you use and either (1) override its append() member function to do, either wchar_t -> UTF-8 (or any other translation) on the fly, or, if you can use Visual Studio 2010, (2) imbue the underlying file stream with, e.g., std::codecvt_utf8<tchar, 0x10FFFF, static_cast<std::codecvt_mode>(std::consume_header | std::little_endian)> facet. For trunk and 1.1.x branches you can do (2) using imbue() member function on *FileAppender. -- VZ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Log4cplus-devel mailing list Log...@li... https://lists.sourceforge.net/lists/listinfo/log4cplus-devel |
From: Václav Z. <vha...@gm...> - 2012-06-06 19:38:53
Attachments:
signature.asc
|
On 06/06/2012 07:30 PM, vvv jjj wrote: > Hi log4cplus-devel Team > > Regarding Unicode support, I impemented a null codeset and imbued to > file stream as mentioned in the url > (http://forums.codeguru.com/showpost.php?p=1741409&postcount=8) in > FileAppender file in FileAppender::open method. Also changed the open > mode of stream with binary option enabled in FileAppender file. > > Please let me know if the above approach has any issues. I think that it is a viable option. Personally, I would suggest using Boost's utf8_codecvt_facet, see <http://www.boost.org/doc/libs/1_49_0/libs/serialization/doc/codecvt.html>. > > Thanks > J.Viswanath > > ------------------------------------------------------------------------ > *From:* vvv jjj <vv...@ya...> > *To:* Václav Zeman <vha...@gm...> > *Cc:* "log...@li..." > <log...@li...> > *Sent:* Friday, 1 June 2012 10:21 PM > *Subject:* Re: [Log4cplus-devel] Unicode Text Logging > > Hi log4cplus Devel Team, > > Thanks Václav Zeman for the detailed explanation. > > I understood that the problem is not with log4cplus library but it is > the behavior of stream in c++. I will try the deriving the > FileAppender and check the output or may be I change the code in > log4cplus as I'm using both RollFileAppender and DailyRollFileAppender. > > Regarding the 2nd options imbue I'm using Visual Studio 2008, so need > to check if that options work or not. > > Thanks again to log4cplus team for giving good support. > > Regards > J.Viswanath > > ------------------------------------------------------------------------ > *From:* Václav Zeman <vha...@gm...> > *To:* vvv jjj <vv...@ya...> > *Cc:* log...@li... > *Sent:* Friday, 1 June 2012 6:52 PM > *Subject:* Re: [Log4cplus-devel] Unicode Text Logging > > On 31 May 2012 19:21, Václav Zeman wrote: > > On 05/31/2012 05:46 PM, vvv jjj wrote: > >> Hi log4cplus Devel Team, > >> > >> Thanks Václav Zeman. > >> > >> I gave Unicode text directly in the cpp file. (Ex: CString str = > >> _T("Ω⅓∂₤◊");) > >> The file is saved with unicode support (the default yes button when > >> Unicode file is saved in Visual Studio 2008). The configuration used > >> is Debug Unicode dynamic library. > >>[...] > I have reproduced your problem on Windows as well. The problem is > Windows problem with its code pages. > > Even though you are using the Debug_Unicode (or Release_Unicode) > configuration, which means that the output stream is std::wfstream, > the output file is always using chars (not wchar_ts). If you insist on > logging characters outside of your Windows code page, then you are > unfortunately (nearly) out of luck for 1.0.4.1. > > The best way to work around this for 1.0.4.1 would be to derive your > own appender from *FileAppender that you use and either (1) override > its append() member function to do, either wchar_t -> UTF-8 (or any > other translation) on the fly, or, if you can use Visual Studio 2010, > (2) imbue the underlying file stream with, e.g., > std::codecvt_utf8<tchar, 0x10FFFF, > static_cast<std::codecvt_mode>(std::consume_header | > std::little_endian)> facet. > > For trunk and 1.1.x branches you can do (2) using imbue() member > function on *FileAppender. > > -- > VZ -- VZ |