In my application deployed on Tomcat, there is a class as follows:
import java.util.logging.Level;
import java.util.logging.Logger;
public abstract class ServiceEndpointApplication extends Application {
final static String LOGGER_NAME = "test";
static {
System.out.println("static init start");
Logger logger = Logger.getLogger(LOGGER_NAME);
logger.setLevel(Level.OFF);
System.out.println("static init end");
}
...
}
Just after starting up Tomcat, I send 50 reqests by using JMeter (50 threads, 1 ramp-up period, 1 loop).
Then tail -f catalina.out
shows the following logs:
Nov 06, 2018 1:36:57 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 64126 ms
static init start
static init end
static init end
static init end
is shown twice!
This behavior happens at a probability of about 10%.
My Question :
What are possible reasons for this strange behavior?
Environment :
Java
Tomcat 7.0.59
I found out the reason. This is caused by -f
option of tail
command.
I reproduced this behavior:
$ tail -f catalina.out
...
Nov 06, 2018 7:18:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 62601 ms
static init start
static init end
static init end
And then I ran tail
without any options:
$ tail catalina.out
...
Nov 06, 2018 7:18:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 62601 ms
static init start
static init end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.