Re: [Log4cplus-devel] how to change log4cplu log file to utf8
Logging Framework for C++
Brought to you by:
wilx
From: Václav Z. <vha...@gm...> - 2014-06-29 18:13:50
|
On 26.6.2014 06:54, Manuj Gupta wrote: > I have been handed a code which uses log4cplus as the logger > application. How can I generate a UTF8 logging file for it?. The > logfile being created by log4cplus is in ASCII format at the moment. > > I have tried the follow > > Setting the file encoding of the log file by following instructions at > Change File Encoding to utf-8 via vim in a script > <http://stackoverflow.com/questions/2311750/change-file-encoding-to-utf-8-via-vim-in-a-script> > > |vi dataLog.txt| > |:set bomb| > |:set fileencoding=utf-8| > |:wq| > > I have also tried changing the .properties file > > |log4cplus.logger.dl=TRACE,DATA| > | | > |log4cplus.appender.DATA=log4cplus::RollingFileAppender| > |log4cplus.appender.DATA.Locale=en-US| > |log4cplus.appender.DATA.File=/usr/vm/log/data/dataLog.txt| > |log4cplus.appender.DATA.MaxFileSize=5000KB| > |log4cplus.appender.DATA.MaxBackupIndex=5| > |log4cplus.appender.DATA.layout=log4cplus::PatternLayout| > |log4cplus.appender.DATA.layout.ConversionPattern=%D{%d/%b/%y %H:%M:%S.%q} %-9c %-5p %m%n| > > I am not sure on the exact version of log4cplus however a locate > resulted in the following > > |/usr/lib/liblog4cplus-1.0.so.4| > |/usr/lib/liblog4cplus-1.0.so.4.0.0| > |/usr/lib/liblog4cplus-1.0.so.4.0.0_load| > |/usr/lib/liblog4cplus.so| > Copying from my SO answer <http://stackoverflow.com/q/24422449/341065>: Since log4cplus 1.1.0-RC10 you can specify locale to be imbued into |std::filestream| used by file appenders. See FileAppender documentation <http://log4cplus.sourceforge.net/docs/html/classlog4cplus_1_1FileAppender.html>, especially the |Locale| property. In your case, try to imbue it with |en_US.UTF-8|. -- VZ |