Take the 2-minute tour ×

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);

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.file and use a file for configuration, or you can set java.util.logging.config.class and use a class to configure the logging.

The logging.properties file in the JRE/lib directory will be used if none of those properties are set (unless the code specifies another logging configuration)

share|improve this answer

Looks like you can set the system property java.util.logging.FileHandler.formatter according to the Java Doc.

share|improve this answer

Your Answer


