I wrote a CXF SOAP client and would like to create numbered log files for each run.
I have tried configuring FileHandler using "logging.properties" file. I have this line there:
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = campaignStatusCXF%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
# Limit the message that are printed on the console to WARNING and above.
java.util.logging.ConsoleHandler.level = WARNING
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
But it does not work just by itself. I had to add FileHandler in the code:
System.setProperty("java.util.logging.config.file", "/logging.properties"); LOG = Logger.getLogger(BulkEmailDownloader.class.getName());
try {
FileHandler logFile;
logFile = new FileHandler("campaignStatus.log");
logFile.setFormatter(new SimpleFormatter());
LOG.addHandler(logFile);
} catch (SecurityException e1) {
} catch (IOException e2) {
}
The problem with this approach is - it simply rewrites the log all the time.
I read numerous examples and answers, for example this, but could not find the answer I am looking for.