views:

269

answers:

1

Hi I currently have this in my .properties file:

java.util.logging.FileHandler.pattern = %h/programName%u%g.log

I would also like to append a timestamp / username to this so its easy to identify log files does anyone know how?

+1  A: 

Since the FileHandler methods don't have a % substitution variable for date, my suggestion would be to format a string that includes the date before passing the string to FileHandler. Something like:

String pattern = String.format("%%h/programName%tYmd%%u%%g.log", today);
FileHandler fh = new FileHandler(pattern);
shoover
can this be done from within a .properties file?
Aly
Ah, I missed the properties file part. That will require a little more thinking.
shoover
Do you have access to programmatically write to the .properties file on program startup? And is this a program that executes and quits, or something that stays loaded (possibly overnight)?
shoover