On Java Development

All things related to Java development, from the perspective of a caveman.

Managing the Logging of Exceptions

without comments


This post shows how to manage the logging of exceptions so that when developing the application the stack trace for the error appears in the Eclipse console. The behavior should change when the application is running on the TEST or PROD server so that the error message is logged to the application’s log file as a fatal error.


The ApplicationContextManager and the Runtime Environment

The code below shows the logic used for exception processing. The error message processing begins on lines 7 and 15 for each of the exception catch phrases. It begins by obtaining the current runtime environment from the ApplicationContextManager to read the value assigned to the runtime environment variable. When it indicates ‘localhost’ the stack trace is logged to the Eclipse console. When it is anything other than that, i.e. TEST or PROD, then the message is logged to the application’s log file.

Written by admin

January 13th, 2015 at 7:20 am

Leave a Reply

You must be logged in to post a comment.