Creating Event Log Source Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss create event log source registry the workings and policies of this site About Us Learn more
Create Event Log Source C#
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack powershell create event log source Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping
Create New Event Log Source
each other. Join them; it only takes a minute: Sign up Does one need to manually create a Windows event log source when installing a Windows service up vote 9 down vote favorite 2 I have developed a Windows service in C#. I have created a installer with Visual Studio 2008, which installs the Windows service. Everything is create event log source command line good so far. I want to make sure that the event source has been created at install time, so that any error/exception conditions at runtime are correctly logged to the Windows event log. Does the event source get automatically created (and removed) as part of the windows service installation (and uninstallation), or do I have to handle this myself and create a custom action to create and delete it as follows? protected override void OnBeforeInstall(IDictionary savedState) { base.OnBeforeInstall(savedState); if (!EventLog.SourceExists(ServiceName)) EventLog.CreateEventSource(ServiceName, "Application"); } protected override void OnAfterUninstall(IDictionary savedState) { base.OnAfterInstall(savedState); if (EventLog.SourceExists(ServiceName)) EventLog.DeleteEventSource(ServiceName); } c# .net windows-services event-log share|improve this question asked Sep 27 '09 at 22:04 Elan 2,16074174 add a comment| 2 Answers 2 active oldest votes up vote 10 down vote accepted It appears to me like the ServiceInstaller automatically creates a DataSource during installation with the same name as the service, so there's no need for any extra code. From the ServiceInstaller documentation When the installation is performed, it automatically creates an EventLogInstaller to install the event log
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev
Event Log Source Schannel
centers Retired content Samples We’re sorry. The content you requested has been removed.
Event Log Source Sidebyside
You’ll be auto redirected in 1 second. Using System Monitoring Components Logging Application, Server, and Security Events How to: delete event log source Create EventLog Component Instances How to: Create EventLog Component Instances How to: Add Your Application as a Source of Event Log Entries How to: Add Your Application as a Source of http://stackoverflow.com/questions/1484605/does-one-need-to-manually-create-a-windows-event-log-source-when-installing-a-wi Event Log Entries How to: Add Your Application as a Source of Event Log Entries How to: Configure EventLog Component Instances How to: Add Your Application as a Source of Event Log Entries How to: Determine If an Event Source Exists How to: Remove an Event Source TOC Collapse the table of content Expand the table of content This documentation is archived and https://msdn.microsoft.com/en-us/library/xz73e171(v=vs.90).aspx is not being maintained. This documentation is archived and is not being maintained. Recommended Version This documentation is archived and is not being maintained. How to: Add Your Application as a Source of Event Log Entries .NET Framework 3.5 Other Versions .NET Framework 3.0 .NET Framework 2.0 Visual Studio .NET 2003 Before your component can write an entry to an event log, you must register it with the event log as a valid source of events. You can do this by using the CreateEventSource method and specifying a string that uniquely identifies your component to the event log. When you write a log entry, the system uses the source you identified to find the appropriate log in which to place your entry. Your EventLog component instance can write to only a single log at a time. Note:By default, if you try to write an entry without first having registered your component as a valid source, the system automatically registers the source with the event log, using the value of the Source property as the source string. In general, create the new event source during the installation of y
centers Retired content Samples Developer Network Developer Sign in https://technet.microsoft.com/en-us/library/hh849768.aspx MSDN subscriptions Get tools PowerShell Gallery Documentation Windows PowerShell Desired State Configuration (DSC) Just Enough Administration (JEA) PowerShell Modules Reference Windows PowerShell SDK PowerShell Gallery Azure PowerShell Community Announcements Community Links Feedback UserVoice Q&A Submissions We’re sorry. The event log content you requested has been removed. You’ll be auto redirected in 1 second. Windows PowerShell 5.0 Microsoft.PowerShell.Management Module Management Cmdlets Management Cmdlets New-EventLog New-EventLog New-EventLog Add-Computer Add-Content Checkpoint-Computer Clear-Content Clear-EventLog Clear-Item Clear-ItemProperty Clear-RecycleBin Complete-Transaction Convert-Path Copy-Item Copy-ItemProperty Debug-Process Disable-ComputerRestore event log source Enable-ComputerRestore Get-ChildItem Get-Clipboard Get-ComputerInfo Get-ComputerRestorePoint Get-Content Get-ControlPanelItem Get-EventLog Get-HotFix Get-Item Get-ItemProperty Get-ItemPropertyValue Get-Location Get-Process Get-PSDrive Get-PSProvider Get-Service Get-TimeZone Get-Transaction Get-WmiObject Invoke-Item Invoke-WmiMethod Join-Path Limit-EventLog Move-Item Move-ItemProperty New-EventLog New-Item New-ItemProperty New-PSDrive New-Service New-WebServiceProxy Pop-Location Push-Location Register-WmiEvent Remove-Computer Remove-EventLog Remove-Item Remove-ItemProperty Remove-PSDrive Remove-WmiObject Rename-Computer Rename-Item Rename-ItemProperty Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service Restore-Computer Resume-Service Set-Clipboard Set-Content Set-Item Set-ItemProperty Set-Location Set-Service Set-TimeZone Set-WmiInstance Show-ControlPanelItem Show-EventLog Split-Path Start-Process Start-Service Start-Transaction Stop-Computer Stop-Process Stop-Service Suspend-Service Test-ComputerSecureChannel Test-Connection Test-Path Undo-Transaction Use-Transaction Wait-Process Write-EventLog TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. New-EventLog Windows PowerShell 5.0 Other Versions Windows PowerShell