0

I'm getting TypeInitializationException, object not set to reference of an object at Logger.Log() in the below code in the service page.

public void Extraction()
        {
            try
            {
                Extraction obj = new Extraction();
                obj.ExtractionNew();
            }
            catch (Exception ex)
            {
                Logger.Log("Extraction failed" + ex.Message);
            }
        }

This is my Logger class and Log function:

namespace BLL
{
    public enum LogFilename
    {
        WebPageLog
    }
    public static class Logger
    {
        private static string errorLogPath;
        private static int logLevels;

        static Logger()
        {
            errorLogPath = ConfigurationManager.AppSettings["ERROR_LOG_PATH"].ToString().Trim();
            logLevels = Convert.ToInt32(ConfigurationManager.AppSettings["LOG_LEVELS"]);
        }

        public static void Log(string message, int Level, string source)
        {
            //Log code
        }
    }
}

From my Service page I can navigate to Log function by pressing f12. But why it gives this exception?

Uwe Keim
  • 36,867
  • 50
  • 163
  • 268
Ashin
  • 129
  • 3
  • 14

0 Answers0