Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Look in the following code:

**FileHandler txtLog = new FileHandler("log/server-%u%g.log", 0, 1, true);**

 txtLog.setFormatter(new SimpleTextFormatter());
            BasicServerConfig config = qs.getBasicConfig();
            log.fine("Getting the log level.. from server.xml, after loading Quick Server...");

I want that this file should be created with each new date (with out time).

share|improve this question
This should be transfered to – Philippe Carriere Dec 3 '09 at 15:58
Don't know if it should or not. As Linux admin, I would much rather the app just behaves like everything most things so it can be used with logrotate. But I don't know Java, so don't know if Java can catch those signals and act like normal programs. – Kyle Brandt Dec 3 '09 at 16:17
As the question is being put, it's a coding question suited for stackoverflow. – MattBianco Mar 31 '11 at 11:02

From the Linux perspective, the general way would be to use logrotate to rotate the logs. Then have you program handle the HUP signal to reopen the new logs and set up lograte to send that signal to program.

If you want to do this all within Java, then you should go ask on .

share|improve this answer
Definitely Stackoverflow... what you want is log4j: is very configurable, and has appenders/plugins for almost everything you might want, including one that can automatically rotate files based on date and size. – mfarver Dec 3 '09 at 14:52
But java is broken, you have no guarantee that flock() type cooperation is going to be honored, since it might not work elsewhere -- Windoze, Mac. Stupid java... (sez the java programmer) – Roboprog Jan 6 '10 at 18:11
P.S. - I don't mean literally broken, just that it disregards current unix conventions for log file handling so as to be annoyingly portable. – Roboprog Jan 6 '10 at 18:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.