Log4J Logging Exceptions
by, 02-24-2012 at 08:27 PM (1318 Views)
Usually it has been seen that user don’t stay bound to follow the rules. Therefore it is general rule to deal, with exceptions. Different exceptions would be discussed in this post which are based upon those boundaries which are crossed by them.
- External Boundaries /Expected Exceptions: Example of this exception is FileNotFoundException. API boundries are crossed by it and gets exposed to users. Such kind of exceptions are enlisted in clause “throws”.They shall be handled with proper care and in a proper way and this handling is dependent at the code that one is developing. At debug level, functions shall be logged. Framework shall instantly catch such exceptions before API interface is crossed. Log the full stack trace at rethrown and info level.
- External Boundaries/Unexpected Exceptions: Example of this kind of exception is NullPointerException. They are not present in thrown clause and are run-time errors or exceptions. It is totally dependent upon the code type developed that how these exceptions would be handled. At debug level, log these exceptions when they get caught.
- Internal Boundaries: All exceptions which are resolved & caught internally. They shall be logged at debug or info level.
- Significant Internal Boundaries: They are applied at the middleware components. Log them at info level.