Now Java9 provide default Logger module in which log can be write in console as well as text or xml file. Java9 default log format is xml.

One can change XML file format to TEXT file format as under:

Open logging.properties file ([JAVA_HOME/config])

Replace java.util.logging.ConsoleHandler.formatter = java.util.logging.XMLFormatter

With

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

XMLFormatter file format

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
  <date>2017-03-26T18:06:23.838177200Z</date>
  <millis>1490551583838</millis>
  <nanos>177200</nanos>
  <sequence>0</sequence>
  <logger>FirstModule</logger>
  <level>INFO</level>
  <class>firstmodule.com.javadeveloperzone.Main</class>
  <method>main</method>
  <thread>1</thread>
  <message>JavaDeveloperZone first log.</message>
</record>
<record>
  <date>2017-03-26T18:06:24.192426100Z</date>
  <millis>1490551584192</millis>
  <nanos>426100</nanos>
  <sequence>1</sequence>
  <logger>FirstModule</logger>
  <level>INFO</level>
  <class>firstmodule.com.javadeveloperzone.Main</class>
  <method>main</method>
  <thread>1</thread>
  <message>JavaDeveloperZone second log.</message>
</record>
</log>

 SimpleFormatter file format

Mar 26, 2017 11:45:47 PM firstmodule.com.javadeveloperzone.Main main
INFO: JavaDeveloperZone first log.
Mar 26, 2017 11:45:47 PM firstmodule.com.javadeveloperzone.Main main
INFO: JavaDeveloperZone second log.

 

Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.
Yes
No
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *