I have been given code that uses log4j as an application for registration. How can I create a UTF8 log file for it ?. The log file created by log4j is currently in ASCII format.
I tried to follow
Configure the log file encoding using the following instructions
vi current :set bomb :set fileencoding=utf-8 :wq
Infact after executing the above log file stops working, i.e. additional logs are not written to the file for some strange reason
I also tried changing the .properties file
log4j.rootLogger=TRACE, logfile log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.encoding=UTF-8 log4j.appender.logfile.File=/usr/vm/log/webconsole/current log4j.appender.logfile.Append=true log4j.appender.logfile.MaxFileSize=5MB log4j.appender.logfile.MaxBackupIndex=1 log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=[%5p] %d{ISO8601} (%F:%M:%L)%n%m%n%n log4j.logger.com.company.npm=ALL log4j.logger.org.apache.axis=OFF
Log file after overflow for some reason is in ASCII format
I am using log4j 1.2.8
When I turned on log4j debugging, I got the following output
@4000000053b16b142afa961c log4j: Parsing for [root] with value=[TRACE, logfile, cdr]. @4000000053b16b142afc630c log4j: Level token is [TRACE]. @4000000053b16b142afe85ec log4j: Category root set to DEBUG @4000000053b16b142aff510c log4j: Parsing appender named "logfile". @4000000053b16b142e3ebccc log4j: Parsing layout options for "logfile". @4000000053b16b143333a0bc log4j: Setting property [conversionPattern] to [[%5p] %d{ISO8601} (%F:%M:%L)%n%m%n%n]. @4000000053b16b1433442f04 log4j: End of parsing for "logfile". @4000000053b16b14343015a4 log4j: Setting property [file] to [/usr/vm/log/webconsole/current]. @4000000053b16b1434331b14 log4j: Setting property [append] to [true]. @4000000053b16b1434350b2c log4j: Setting property [maxFileSize] to [100KB]. @4000000053b16b14343885cc log4j: Setting property [maxBackupIndex] to [1]. @4000000053b16b14343a79cc log4j: Setting property [encoding] to [UTF-8]. @4000000053b16b14343d311c log4j: setFile called: /usr/vm/log/webconsole/current, true @4000000053b16b1434937edc log4j: setFile ended @4000000053b16b143496a774 log4j: Parsed "logfile" options. @4000000053b16b1434a97fac log4j: Parsing appender named "cdr". @4000000053b16b150111c014 log4j: Parsed "cdr" options. @4000000053b16b1501166394 log4j: Parsing for [com.company.npm] with value=[ALL]. @4000000053b16b150118d87c log4j: Level token is [ALL]. @4000000053b16b15011abcdc log4j: Category com.company.npm set to ALL @4000000053b16b150122003c log4j: Handling log4j.additivity.com.company.npm=[null] @4000000053b16b150123d4fc log4j: Finished configuring. @4000000053b16b17086f0114 log4j: rolling over count=102406 @4000000053b16b1708703d7c log4j: maxBackupIndex=1 @4000000053b16b170910fdd4 log4j: Renaming file /usr/vm/log/webconsole/current to /usr/vm/log/webconsole/current.1 @4000000053b16b1709140b14 log4j: setFile called: /usr/vm/log/webconsole/current, false @4000000053b16b170916494c log4j: setFile ended
java logging utf-8 log4j
Manuj
source share