Log exception to file in c# .net core application explained

In production environment when any bug gets reported at that time as developer wants to get the exception details of bug to resolve the issue on high priority.
In some case there might be situation where exception is not logged in table but developer wants to check the bug immediately. for that purpose we need to write the
exception details including stack trace of bug in file. To implement this easily i am going to demonstrate the implementation of custom logging in file as below.

First we need to construct the exception and logger method in custom logger class as shown below.


public class CustomLogger { public static List<string> ConstructExceptionDetails(Exception ex,string FunctionName) { return new List<string>() { $"{DateTime.Now} - {FunctionName}", $"Exception: {ex.Message}", $"StackTrace: {ex.StackTrace}", $"InnerException: {ex.InnerException?.…

Creation of the virtual directory failed issue whle opening the older version projects in VS2017[solved]

I attempted to load the new VS2015 project in VS2017, but it immediately failed to load.and i am getting below error popup

Creation of the virtual directory http://localhost:32999/
failed with the error: Filename: redirection.config
Error: Cannot read configuration file

there are two solution for this issue

1) Renaming applicationhost.config :


  1.     Close VS2017
  2.     Go into folder %userprofile%\Documents\IISExpress\config
  3.     Rename applicationhost.config
  4.     Restart VS and load the solution/project
  5.     VS should have recreated applicationhost.config, and project should load


2) Copy config files to IISExpress directory

copy all files from

    C:\Program Files\IIS Express\config\templates\PersonalWebServer

to

    %userprofile%\Documents\IISExpress\config


any of above solution will resolve your problem..

Comments

Popular posts from this blog

Restore the lost focus of Auto post back controls in asp.net update Panel control

Add Comma automatically while entering amounts in textbox using Javascript

Devexpress Datebox date formatting in angular 6 with example