1

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

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
Community
  • 1
  • 1
Manuj
  • 286
  • 1
  • 3
  • 12

1 Answers1

1

Since log4cplus 1.1.0-RC10 you can specify locale to be imbued into std::filestream used by file appenders. See FileAppender documentation, especially the Locale property. In your case, try to imbue it with en_US.UTF-8.

wilx
  • 16,767
  • 5
  • 53
  • 109