I have a java program which is using the default XML logging as no formatter is defined, I am wondering if there is a way to change this outside of modifying the code or adding a logging.properties file(it has none atm). Is there a way to specify/change the default file handler from XML to SimpleFormatter for Java.util.log? It’s logging configuration is hard coded:
fh = new FileHandler("/path/to/logfile",true);
logger.addHandler(fh);
Rather then having to add fh.setFormatter(new SimpleFormatter()) in the code here, I am wondering if there is anyway via command line that I can specify SimpleFormatter to be used as the default formatter rather then the XML formatter which it defaults to?
Thanks for any thoughts
You can specify how logging should be done in several ways, and they are all described in the javadoc for LogManager.
You can set the system property
java.util.logging.config.fileand use a file for configuration, or you can setjava.util.logging.config.classand use a class to configure the logging.The
logging.propertiesfile in theJRE/libdirectory will be used if none of those properties are set (unless the code specifies another logging configuration)