D
Dave
Hello,
I'm having trouble logging messages while the JVM is shutting down.
It seems that the logging infrastructure silently breaks as soon as
shutdown starts. In the program below, after sending a ctrl-c, I
still get "."s, but no logging messages, and no error messages either.
It seems to me that this limits logging in a crucial way, and I'd
like to find out that there is a way around it. Can anyone shed light
on this?
Java 1.4.1_03-b02 running on WinXP
import java.util.logging.*;
public class testing {
static Logger logger = Logger.getLogger("testing");
public static void main(String[] args) {
Thread shutdown_thread = new Thread(new Runnable() {
public void run() {
System.out.println("Shutting down");
try{
Thread.sleep(1000);
}
catch(InterruptedException e){
System.out.println("Sleep Interrupted");
}
System.out.println("down");
}});
Runtime.getRuntime().addShutdownHook(shutdown_thread);
try {
while (true) {
System.err.print(".");
logger.severe("+");
try{
Thread.sleep(100);
}
catch(InterruptedException e){
System.out.println("Sleep Interrupted");
}
}
} catch (Exception ee) {
System.out.println("done");
}
}
}
I'm having trouble logging messages while the JVM is shutting down.
It seems that the logging infrastructure silently breaks as soon as
shutdown starts. In the program below, after sending a ctrl-c, I
still get "."s, but no logging messages, and no error messages either.
It seems to me that this limits logging in a crucial way, and I'd
like to find out that there is a way around it. Can anyone shed light
on this?
Java 1.4.1_03-b02 running on WinXP
import java.util.logging.*;
public class testing {
static Logger logger = Logger.getLogger("testing");
public static void main(String[] args) {
Thread shutdown_thread = new Thread(new Runnable() {
public void run() {
System.out.println("Shutting down");
try{
Thread.sleep(1000);
}
catch(InterruptedException e){
System.out.println("Sleep Interrupted");
}
System.out.println("down");
}});
Runtime.getRuntime().addShutdownHook(shutdown_thread);
try {
while (true) {
System.err.print(".");
logger.severe("+");
try{
Thread.sleep(100);
}
catch(InterruptedException e){
System.out.println("Sleep Interrupted");
}
}
} catch (Exception ee) {
System.out.println("done");
}
}
}