I wrote the method to check the working functionality of the logger as follows,
package test;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class test1{
private static Logger logger = Logger.getLogger(test1.class);
public static void main(String args[])
{
System.out.println("time 1 "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
System.out.println("time 2 "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
logger.log(Level.INFO,"Eror "+System.currentTimeMillis());
System.out.println("time 3 "+System.currentTimeMillis());
System.out.println("time 4 "+System.currentTimeMillis());
System.out.println("time 5 "+System.currentTimeMillis());
}
}
And i got the output as follows,
time 1 1367325027239
time 2 1367325027247
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027239
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027247
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027248
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027249
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027250
Apr 30, 2013 6:00:27 PM test.test1 main
INFO: Eror 1367325027250
time 3 1367325027251
time 4 1367325027251
time 5 1367325027251
My question is, will the program control waits until the logger completes its process
(i.e writing the message into the log file according to the configuration),
Or logger will execute independently after returning the control to the calling code.
(From the above code it can be seen that logger takes some time , but my thought is that within that time the file operation cannot be completed)