2

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?

Aly
  • 15,865
  • 47
  • 119
  • 191

1 Answers1

3

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
  • 3,071
  • 1
  • 29
  • 40
  • Ah, I missed the properties file part. That will require a little more thinking. – shoover Dec 07 '09 at 18:07
  • 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 Dec 07 '09 at 18:07