How to change log4j log file to utf8

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 
+7
java logging utf-8 log4j
source share

No one has answered this question yet.

See similar questions:

0
Java Log4j UTF-8 encoding with special characters

or similar:

3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3061
grep file, but show some surrounding lines?
908
How to have git log show filenames such as svn log -v
one
Log4j deletes logs older than one month
0
Why is log4j registered in two separate files?
0
Added Log4j File Rolling with DateTimestamp to minimized log file?
0
Where does log4j write logs in cluster mode?
0
Does Log4j stop registering in a file (File Appenders) when I open / edit a file?
0
How to add and fix print flow in a log file using log4j through a properties file

All Articles