[JAVA] Format of the log output by Tomcat itself in Tomcat 8

** Notes on migrating from Tomcat 7 to Tomcat 8 **

change point


2015/01/16 9:26:31 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina


16-Jan-2015 9:26:31.518 INFO [main] org.apache.catalina.core.StandardService.startInternal service Starts Catalina

What was two lines has been changed to one line.

Back to 2 lines

To get this back to the original two lines, go to the following in conf / logging.properties


java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter

By changing to the following, it becomes the same two lines as Tomcat 7. (OneLineFormatter-> SimpleFormatter)


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

This will display two lines as shown below.


1 15, 2015 12:06:25 pm org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina

If you look closely, the date format has also changed

Until now, it was processed by format held in java.util.logging.SimpleFormatter, The format obtained from Java 7 with getSimpleFormat of sun.util.logging.LoggingSupport is used.

You can get the same contents as in Java 6 by adding the following to conf / logging.properties of Tomcat.


java.util.logging.SimpleFormatter.format = %1$tY/%1$tm/%1$td %1$tk:%1$tM:%1$tS %2$s%n%4$s: %5$s%6$s%n

It's finally the same as Tomcat 7 + Java 6.


2015/01/16 9:26:31 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina

Supplementary information

Date format confirmation source

package jp.kajiken.format;

import java.text.MessageFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;

public class TestFormat {

	public static void main(String[] args) {
		//Date to test
		Calendar cal = new GregorianCalendar(2015, 0, 2, 8, 50, 59);
		Date dat = new Date(cal.getTimeInMillis());

		// Java6
		System.out.print(new MessageFormat("{0,date} {0,time}").format(new Object[]{dat}));
		System.out.println(" org.apache.catalina.core.StandardService startInternal");
		System.out.println("information:Start the service Catalina");

		// Java7
				"%1$tY/%1$tm/%1$td %1$tk:%1$tM:%1$tS %2$s%n%4$s: %5$s%6$s%n");
		LogRecord log = new LogRecord(Level.INFO, "Start the service Catalina");
		SimpleFormatter sf = new SimpleFormatter();

Execution result


2015/01/02 8:50:59 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina
2015/01/02 8:50:59 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina

I was able to successfully reproduce the state before the transition. The reason I'm doing this is that there was an existing script that was processing using this string ...

Recommended Posts

Format of the log output by Tomcat itself in Tomcat 8
Output Spring Boot log in json format
Put the date (e.g. yyyy-MM-dd) in the log file output by logback
Output in multiples of 3
Prepare the execution environment of Tomcat in IntelliJ Community
Access the war file in the root directory of Tomcat
Find the approximate value of log (1 + x) in Swift
Log output in Json format using lograge / lograge-sql with RubyOnRails
Install by specifying the version of Django in the Docker environment
I want to change the log output settings of UtilLoggingJdbcLogger
Get a proxy instance of the component itself in Spring Boot
Output the difference between each field of two objects in Java
[Java] Output by FormatStyle of DateTimeFormatter
Implementation of asynchronous processing in Tomcat
Log output to file in Java
Replace preview by uploading by clicking the image in file_field of Rails
Log output of WebServiceTemplate request / response
Order of processing in the program
About the log level of java.util.logging.Logger
[Java] Output by specifying the format with printf% s,% d,% f [Format specifier]
Get the value of enum saved in DB by Rails with attribute_before_type_cast
Get the result of POST in Java
Output system log by Spring AOP technology
The identity of params [: id] in rails
Implementation of multi-tenant asynchronous processing in Tomcat
The process of understanding Gemfile by non-engineers
Output HTTP header of google-http-client to log
[Swift] Termination of the program by assertion
The story of AppClip support in Anyca
Output Date in Java in ISO 8601 extended format
Output of the book "Introduction to Java"
The story of writing Java in Emacs
Format the contents of LocalDate with DateTimeFormatter
The contents of the data saved by CarrierWave.
Sort by multiple fields in the class
Write the movement of Rakefile in the runbook
Inspect the contents of log output during Java unit test (no mock used)
Add arbitrary parameters to the URL output by <h: outputScript> <h: outputStylesheet> of JSF
Call a method of the parent class by explicitly specifying the name in Ruby
Be careful about upgrade if you use | etc. in the URL of Tomcat
Format the date and time given by created_at
[Order method] Set the order of data in Rails
Has the content of useBodyEncodingForURI changed from Tomcat8?
Preventing mistakes in the Logger name by copying
[Apache Camel] Easy output of throughput to log
The story of low-level string comparison in Java
[Java] Handling of JavaBeans in the method chain
I want to output the day of the week
The story of making ordinary Othello in Java
About the idea of anonymous classes in Java
The story of learning Java in the first programming
Measure the size of a folder in Java
Output request and response log in Spring Boot
Prepare for log output using log4j in Eclipse.
Log4j 2 Understanding the underlying concepts of the log system
Manage the version of Ruby itself with rbenv
Feel the passage of time even in Java
Output of how to use the slice method
[Java] Judgment by entering characters in the terminal
Replaced Tomcat 8.5 log output with Log4j2.8 or later
[Java] Something is displayed as "-0.0" in the output