About Java Hub

Java Learners Hub


Super friendly <br/>code & developer communities

Super friendly
code & developer communities

A place for coders and developers to share, learn and grow together.

Back to Hub

How to Log an Exception in java?

1      Reply

Use a logger.fatal to log the expection

try {
	// Code that generates an Exception
} catch (Exception e) {
	logger.fatal("Caught Exception", e);
	throw e;
}

The logger can be declared as

final static Logger logger = 
LogManager.getLogger(MyProgram.class.getName));
Reply