Having trouble with Logging Application Block (EntLib 5) on Windows Server 2003R2
Typical scenario, I am using EntLib 5.0-A开发者_JAVA技巧pril 2010 Logging on my development machine and everything works like a charm, when I try to put in production on our web server, it does not work.
Development machine is Windows 7 using VS2008. Production server is Windows Server 2003 R2 with Microsoft .NET Framework 3.5 with Service Pack 1.
I am including the LAB DLLs in the project (Common, Logging, ServiceLocation), not in the GAC.
Any ideas?
thanks in advance
It turns out that since I was running the web app from VS run as an administrator, the LogSource is created for me. When in production, the app is run with normal privileges and requires the LogSource to be created by an admin. Check out the following:
http://entlib.codeplex.com/wikipage?title=Why%20are%20messages%20not%20logged?&referringTitle=EntLib%20FAQ
Create a console application and write these lines:
class Program
{
static void Main(string[] args)
{
System.Diagnostics.EventLog.CreateEventSource("Enterprise Library Logging", "Application");
System.Diagnostics.EventLog.WriteEntry("Application", "Sample error", System.Diagnostics.EventLogEntryType.Error);
}
}
Copy the exe file to the Server , and run it as Administrator. Then , in Event Viewer, you'll see the message "Sample error" to ensure the lines were executed.
It will solve your problem.
精彩评论