This project demonstrates the Dependency Inversion Principle (DIP) using a logging system in .NET.
- High-level modules (
Application) depend only on theILoggerinterface. - Low-level modules (
ConsoleLogger,FileLogger) implement this interface. - This allows loggers to be swapped freely without modifying business logic.
DependencyInversionLogger/
│── DependencyInversionLogger.sln
│── .editorconfig
│
├──── DependencyInversionLogger/
│ ├── ILogger.cs
│ ├── ConsoleLogger.cs
│ ├── FileLogger.cs
│ ├── Application.cs
│ └── Program.cs
│
└─── DependencyInversionLogger.Tests/
├── ConsoleLoggerTests.cs
└── FileLoggerTests.cs
From the root folder (DependencyInversionLogger/):
# Build the solution
dotnet build
# Check code formatting
dotnet format --verify-no-changes
# Run tests
dotnet test
# Run the application
dotnet run --project DependencyInversionLogger- Console logs will appear in the terminal.
- File logs are written to
logs/app.log. The program automatically creates thelogsfolder if it does not exist.
Tip: You can check the log data by opening the file
logs/app.login any text editor after running the application.
- Kallepally Sai Kiran (112201044) → Implemented in .NET, designed with Dependency Inversion Principle.