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?.…

Error The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) while WMI script execution [resolved]

WMI(Windows Management Instrumentation) is powerful and flexible tool  when used correctly, it can deliver the best and most important information about your computers, servers and notebooks. 
But when connecting to the remote machine fails then following error can be occurred.

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

To resolve error you need to cross verify the below checklist to resolve the above error.

  • Verity that "Windows Management Instrumentation" is running in the remote machine and set it to auto start after restart.
  • Verify that you are entered correct host name or IP Address
  • you need to check that "Remote Procedure Call (RPC)" is running in the remote machine and set it to auto start after restart.
  • you need to check that "TCP/IP NetBIOS Helper" is running in the remote machine and set it to auto start after restart.
  • Need to enable Windows Management Instrumentation (WMI) rule in windows firewall in order to add Bot-Station in Cockpit and following is the steps to do so.
  • Go To Windows Firewall >> Allow app or feature through windows firewall >> Enable Domain, public, home/work Privilege for Windows Management Instrumentation(WMI).
After checking above steps you can resolve the above issue. 

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