** Notes on migrating from Tomcat 7 to Tomcat 8 **
catalina.out
2015/01/16 9:26:31 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina
catalina.out
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.
To get this back to the original two lines, go to the following in conf / logging.properties
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)
conf/logging.properties
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
This will display two lines as shown below.
catalina.out
1 15, 2015 12:06:25 pm org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina
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.
conf/logging.properties
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.
catalina.out
2015/01/16 9:26:31 org.apache.catalina.core.StandardService startInternal
information:Start the service Catalina
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");
System.out.println("---");
// Java7
System.setProperty("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");
LogRecord log = new LogRecord(Level.INFO, "Start the service Catalina");
log.setSourceClassName("org.apache.catalina.core.StandardService");
log.setSourceMethodName("startInternal");
log.setMillis(dat.getTime());
SimpleFormatter sf = new SimpleFormatter();
System.out.println(sf.format(log));
}
}
Execution result
stdout
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