Enterprise Library Logging not logging to Event Log from ASP.NET

前端 未结 4 2046
清歌不尽
清歌不尽 2021-02-19 23:16

I spent a day trying to make Ent Lib Logging work and log anything into database or event log. I have a web application and console application with the same Ent Lib config but

4条回答
  •  甜味超标
    2021-02-19 23:45

    or use this code....

     public static void RunSnippet(string logName, string eventSource)
    {
        // this will throw an exception if you don't have admin rights
        if (!EventLog.SourceExists(eventSource))
        {
            System.Diagnostics.EventLog.CreateEventSource(eventSource, logName);
            Console.WriteLine("Event Log and Source: {0},{1} were created successfully.",logName, eventSource);
        }
        else
        {
            Console.WriteLine("Event log/source: {0}/{1} already exists",logName, eventSource);
        }
        Console.WriteLine("Done");
    
    }
    

提交回复
热议问题