I am trying to enable Amazon Web Services SDK logging by using the java.util.logging framework instead of log4j. I have managed to get it working and the logs go into a file specified by java.util.logging.FileHandler.pattern in the properties file.
My log.properties file
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
handlers=java.util.logging.FileHandler
com.amazonaws.request.level=FINE
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.pattern=./javalog.log
What I am looking for is a way to set the file name at runtime.
I tried the following options
Option 1: In the properties file: Set the following java.util.logging.FileHandler.pattern=${mylogfile}
and then in the main() function of my java program, call System.setProperty("mylogfile", logName);
Option 2: Delete the line "java.util.logging.FileHandler.pattern" from the properties file.
Instead, call System.setProperty("java.util.logging.FileHandler.pattern", logName);
Both these options do not work.
Ps: In case of log4j, option 1 works fine.
Any idea how I can customize the log file for SDK logging dynamically ?
Thanks Vijay