1. find and copy $JAVA_HOME/jre/lib/logging.properties to C:/myLogProperties/logging.properties
2. modify C:/myLogProperties/logging.properties as
Modify:
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
java.util.logging.FileHandler.pattern = C:/myLogProperties/myLog.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level = ALL
Add:
java.util.logging.FileHandler.level = ALL
com.myPackages.MyClass.level = ALL
3. use level fine to log, so modify the java application:
Add:
private static Logger logger = Logger.getLogger("com.myPackages.MyClass");
public void myMethod....(){
logger.log(Level.FINE,"Miss Fine");
...
}
4. Execute the application with -D parameter :
java -Djava.util.logging.config.file=C:/myLogProperties/logging.properties myApplication
5. See console or C:/myLogProperties/myLog.log
|