the slightly confusing pattern property of FileHandler can be used for this
handlers=java.util.logging.FileHandler
# Default global logging level.
.level=INFO
#logging level for the foo.bar package
foo.bar.level=CONFIG
java.util.logging.FileHandler.pattern=%h/java%u.log
A pattern consists of a string that includes the following special components that will be replaced at runtime:
"/" the local pathname separator
"%t" the system temporary directory
"%h" the value of the "user.home" system property
"%g" the generation number to distinguish rotated logs
"%u" a unique number to resolve conflicts
"%%" translates to a single percent sign "%"
If you want to log to multiple files then you can do it by set up multiple handlers for multiple named loggers
#FileHandler for file1
java.util.logging.FileHandler.pattern = logging_property_test.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
#FileHandler for file2
logging.FileHandler2.pattern = logging_property_test2.log
logging.FileHandler2.limit = 50000
FileHandler.count = 1
logging.FileHandler2.formatter = java.util.logging.SimpleFormatter
#setting handler for logger1
logging.PropertyTestingLogger.handlers=java.util.logging.FileHandler
#setting handler for logger2
logging.PropertyTestingLogger2.handlers=logging.FileHandler2
as you can see the trick is that there is a logging.FileHandler2 that is a custom class and does nothing but extends the FileHandler
package logging;
import java.io.IOException;
import java.util.logging.FileHandler;
public class FileHandler2 extends FileHandler {
public FileHandler2() throws IOException, SecurityException {
super();
}
}
Background :
unfortunately the creators of Java were not expecting anyone to log into multiple files. If you look at the source of java.util.logging.FileHandler you will find, that the pattern property is loaded by the class name :
public class FileHandler extends StreamHandler {
private String pattern;
private void configure() {
String cname = getClass().getName();
pattern = manager.getStringProperty(cname + ".pattern", "%h/java%u.log");