Logging Exceptions with Custom Framework

This program demonstrates custom logging of exceptions.

Problem Statement

Write a Java program that logs exceptions using a custom logger class.

Source Code

1 class Logger {
2 public static void log(Exception e){
3 System.out.println("Eduinq Log: "+e.getClass().getSimpleName()+" - "+e.getMessage());
4 }
5 }
6 public class CustomLoggingExample {
7 public static void main(String[] args) {
8 System.out.println("Eduinq Custom Logging Example");
9 try {
10 int result=10/0;
11 } catch(Exception e) {
12 Logger.log(e);
13 }
14 }
15 }

Program Output

					Eduinq Custom Logging Example
Eduinq Log: ArithmeticException - / by zero
				

Explanation

Custom logger centralizes exception logging. - Provides consistent format for error messages. - Improves maintainability and monitoring. - In enterprise systems, custom logging integrates with monitoring tools. Conclusion: Shows custom logging of exceptions.

Quick Links to Explore