开发者

enterprise library not logging

I'm logging to event开发者_C百科 log using Ent Lib 5. When I run the application on my Windows 7 machine everything works. But when I deploy it on a WindowsServer 2008 it just stops logging. It doesn't write anything to event log. On both machines Ent Lib 5 is installed.

So what do you think? What can be the problem?


It's a common situation when logging to the Windows Event Log. It's likely due to the fact that the event source is not registered on your Windows Server 2008. When you run it on your dev machine, you (like most developers) probably have admin privileges and the .NET framework automatically creates event sources the first time you use them. Any application without admin privileges cannot create event source and therefore logging fails. The app continues to run as the philosophy of the Logging block is to be non-distracting, but nothing gets logged.

When deploying your application, you should include an installer class to create your event sources. For development, a quick solution is to use Windows PowerShell. Run an elevated PowerShell process, and use this command:

[System.Diagnostics.EventLog]::CreateEventSource(sourceName, logName)

to create your event source for the given log.

Alternatively, run InstallUtil over EntLib assemblies.There's a InstallServices.bat that ships with EntLib that will do it for you.

See more in this Codeplex discussion.


You can also add your event source manually with regedit.

See this MSDN article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜