Total Page Preview:   000000000545

What is logging in Asp.Net Core MVC in English and Hindi

Logging in English

In ASP.NET Core MVC, logging is essential for monitoring and troubleshooting your application. You can use the built-in logging framework to capture various events, errors, and information throughout your application's lifecycle. Here's a step-by-step example of how to set up logging in an ASP.NET Core MVC application:
1-Create a New ASP.NET Core MVC Application:
Start by creating a new ASP.NET Core MVC application using your preferred development environment, such as Visual Studio or Visual Studio Code.
2-Add the Logging Services:
Ensure that you have the necessary logging services configured in your Startup.cs file. You can configure various logging providers like Console, Debug, File, or third-party providers like Serilog or NLog.
In the ConfigureServices method, add the following code to configure the logging services:
3-Inject ILogger into Controllers or Services:
You can inject an ILogger<T> instance into your controllers, services, or other components that require logging. Replace T with the name of the class where you want to use logging.

4-Use Logging in Your Code:
You can use the _logger instance to log messages at different log levels (e.g., Information, Warning, Error, Debug) within your controller methods or services.
5-Configure Logging Levels:
You can configure the minimum logging level for different providers in your appsettings.json file. Here's an example:
6-View Logs:
Depending on the configured log providers, you can view logs in the console, debug output window, or log files (if you added file-based logging).
This example demonstrates how to set up basic logging in an ASP.NET Core MVC application. You can customize it further by adding additional logging providers, configuring log formats, or integrating third-party logging libraries for more advanced logging scenarios.

Logging in Hindi

ASP.NET Core MVC mein logging ek aham hissa hota hai jo aapke application ke chalne aur samasya samadhan ke liye mahatvapurna hota hai. Aap is built-in logging framework ka upayog karke aapke application ke jivan cycle ke alag-alag ghatnayein, errors, aur jankari ko capture kar sakte hain. 


Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn :





Facebook User: