mengoni
mengoni

Reputation: 258

How to set character encoding to ServletContext logs in Tomcat

From my servlet I call the method:

getServletContext().log("Può chiedermi il saldo");

But in Tomcat 8.5 log file (/tomcat/logs/localhost.yyyy-mm-dd.log) I obtain the text with wrong encoding:

 Pu? chiedermi il saldo

Anyone knows how to set logs charset to ISO-8859-1?

Upvotes: 1

Views: 1249

Answers (1)

Konstantin Kolinko
Konstantin Kolinko

Reputation: 3946

See documentation.

The encoding used by org.apache.juli.FileHandler or AsyncFileHandler (that writes the file) is configured by its .encoding property. The configuration properties are listed in Javadoc for the class.

I usually explicitly configure it to use UTF-8

2localhost.org.apache.juli.AsyncFileHandler.encoding=UTF-8

Upvotes: 2

Related Questions