I am trying to deploy app to Windows Server 2008 R2. Ent Lib works fine on my dev box but when I deploy the application to the Windows Server 2008 R2 - it does not work: there is no error, but the logs are silently ignored. In this particular case I am trying to write to the event log. The same app works on my box. Any idea why?
Here is how I a开发者_Python百科m configuring it:
builder.ConfigureLogging()
.WithOptions
.DoNotRevertImpersonation()
.LogToCategoryNamed(Constants.Logging.Category.EventLog)
.SendTo.EventLog(Constants.Logging.EventLogTraceListener)
...
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
I am writing to the log as follows: "Can not process cancellation request. Request: {0} not found." .FormatWith("Empty") .ToLogEntry() .CategorizedAs(Constants.Logging.Category.EventLog) .TitledAs("this title") .Write();
It writes correctly to the event log in the development environment, but not when code is moved to the target environment. There are no errors, no exceptions, the log message is silently ignored.
Any idea why?
With the Event Log this is almost always permissions. Try setting Logging Errors & Warnings
to a file trace listener that writes to file you know you have write permission on to see if you are getting any errors.
PRB: "Requested Registry Access Is Not Allowed" Error Message When ASP.NET Application Tries to Write New EventSource in the EventLog may help you (assuming you have a permission problem).
精彩评论