Logging exception with java.util.logging.Logger#log() to file only

R

Royan

I'm logging exceptions with java.util.logging.Logger#log() (i can't
use anything apart from standard Java API) and i don't want any stack
trace to appear in stdout or stderr is there any way I can filter or
redirect all output that is produced buy this method into the file
only?
 
A

Andrea Francia

Royan said:
I'm logging exceptions with java.util.logging.Logger#log() (i can't
use anything apart from standard Java API) and i don't want any stack
trace to appear in stdout or stderr is there any way I can filter or
redirect all output that is produced buy this method into the file
only?

You can use Level.FINE to log exception and Level.INFO for others message.

Then you can configure the ConsoleHandler to output only the the message
above the INFO level and the FileHandler to output ALL messages.
These configurations are done in the logging.properties configuration file.
There is a global logging.properties file located in your {JRE}/lib
directory, but you can use your own with:

java -Djava.util.logging.config.file=mylogging.properties
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top