Does writing to java.Logger automatically flush the buffer?

Does writing to java.Logger automatically flush the buffer?
ie:
// error log
FileHandler fh1 = new FileHandler("C:\\XSELL\\weberrorlog%g.txt", limit, numLogFiles);
fh1.setFormatter(new SimpleFormatter()); // remove this to switch back to XML
errorLog = Logger.getLogger("");
errorLog.addHandler(fh1);
errorLog.severe("Error!!");
// would data be flushed here or would I have to call fh1.flush() to 100% ensure?

Many thanks
andy_baptisteAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

contactkarthiCommented:
flush the file handler

fh1.flush();
fh1.close();
andy_baptisteAuthor Commented:
Does the Logger class not do that by default though?

I'm concerned that if the buffer is not flushed when support people open the log file they will not get an upto date picture, so if it does flush after every write I was thinking I may have to explicitly do this.

If I do have to call flush myself I presume it's just flush and not close?

Many thanks...
 private static Logger errorLog = Logger.getLogger("");
  static {
	    try {
			int limit = 1000000; // 1 Mb
			int numLogFiles = 5;
			
			// error log
			FileHandler fh1 = new FileHandler("C:\\XSELL\\weberrorlog%g.txt", limit, numLogFiles);
			fh1.setFormatter(new SimpleFormatter()); // remove this to switch back to XML
			errorLog = Logger.getLogger("");
			errorLog.addHandler(fh1);
			// usage/audit log
			FileHandler fh2 = new FileHandler("C:\\XSELL\\webauditlog%g.txt", limit, numLogFiles);
			fh2.setFormatter(new SimpleFormatter()); // remove this to switch back to XML
			auditLog = Logger.getLogger("");
			auditLog.addHandler(fh2);
	    }
	    catch (IOException e) {
	      e.printStackTrace();
	    }
	}

Open in new window

Mick BarryJava DeveloperCommented:
pretty sure it does flush after each entry is written

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andy_baptisteAuthor Commented:
Many thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.