Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enterprise library not logging

I'm logging to event 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?

like image 250
rovsen Avatar asked Sep 11 '26 23:09

rovsen


1 Answers

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.

like image 95
Grigori Melnik Avatar answered Sep 15 '26 08:09

Grigori Melnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!