Logging Exceptions with Framework

This program demonstrates logging exceptions using Java logging framework.

Problem Statement

Write a Java program that logs exceptions using java.util.logging.Logger.

Source Code

1 import java.util.logging.*;
2 public class LoggingFrameworkExample {
3 private static final Logger logger=Logger.getLogger("EduinqLogger");
4 public static void main(String[] args) {
5 System.out.println("Eduinq Logging Framework Example");
6 try {
7 int result=10/0;
8 } catch(Exception e) {
9 logger.log(Level.SEVERE,"Eduinq Exception Occurred",e);
10 }
11 }
12 }

Program Output

					Eduinq Logging Framework Example
SEVERE: Eduinq Exception Occurred
java.lang.ArithmeticException: / by zero
				

Explanation

Logging framework provides structured error reporting. - Logs include severity levels and stack trace. - Improves monitoring and debugging. - In enterprise systems, logging integrates with monitoring tools. Conclusion: Shows logging exceptions with framework.

Quick Links to Explore