EventLog.Source Property (System.Diagnostics) (2024)

Gets or sets the source name to register and use when writing to the event log.

public: property System::String ^ Source { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.SettingsBindable(true)]public string Source { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]public string Source { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]public string Source { get; set; }
[System.ComponentModel.SettingsBindable(true)][System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]public string Source { get; set; }
[<System.ComponentModel.SettingsBindable(true)>]member this.Source : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]member this.Source : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]member this.Source : string with get, set
[<System.ComponentModel.SettingsBindable(true)>][<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]member this.Source : string with get, set
Public Property Source As String

Property Value

String

The name registered with the event log as a source of entries. The default is an empty string ("").

Attributes

Exceptions

ArgumentException

The source name results in a registry key path longer than 254 characters.

Examples

The following example creates the source MySource if it does not already exist, and writes an entry to the event log MyNewLog.

#using <System.dll>using namespace System;using namespace System::Diagnostics;using namespace System::Threading;int main(){ // Create the source, if it does not already exist. if ( !EventLog::SourceExists( "MySource" ) ) { EventLog::CreateEventSource( "MySource", "MyNewLog" ); Console::WriteLine( "CreatingEventSource" ); } // Create an EventLog instance and assign its source. EventLog^ myLog = gcnew EventLog; myLog->Source = "MySource"; // Write an informational entry to the event log. myLog->WriteEntry( "Writing to event log." ); Console::WriteLine( "Message written to event log." );}
using System;using System.Diagnostics;using System.Threading;class MySample{ public static void Main(){ // Create the source, if it does not already exist. if(!EventLog.SourceExists("MySource")) { // An event log source should not be created and immediately used. // There is a latency time to enable the source, it should be created // prior to executing the application that uses the source. // Execute this sample a second time to use the new source. EventLog.CreateEventSource("MySource", "MyNewLog"); Console.WriteLine("CreatingEventSource"); Console.WriteLine("Exiting, execute the application a second time to use the source."); // The source is created. Exit the application to allow it to be registered. return; } // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "MySource"; // Write an informational entry to the event log. myLog.WriteEntry("Writing to event log."); Console.WriteLine("Message written to event log."); }}
Option ExplicitOption StrictImports System.DiagnosticsImports System.ThreadingClass MySample Public Shared Sub Main() ' Create the source, if it does not already exist. If Not EventLog.SourceExists("MySource") Then EventLog.CreateEventSource("MySource", "MyNewLog") Console.WriteLine("CreatingEventSource") End If ' Create an EventLog instance and assign its source. Dim myLog As New EventLog() myLog.Source = "MySource" ' Write an informational entry to the event log. myLog.WriteEntry("Writing to event log.") Console.WriteLine("Message written to event log.") End SubEnd Class

Remarks

The event source indicates what logs the event. It is often the name of the application, or the name of a subcomponent of the application, if the application is large. Applications and services should write to the Application log or a custom log. Device drivers should write to the System log.

You only need to specify an event source if you are writing to an event log. Before writing an entry to an event log, you must register the event source with the event log as a valid source of events. When you write a log entry, the system uses the Source property to find the appropriate log in which to place your entry. If you are reading the event log, you can either specify the Source, or a Log and MachineName.

Note

You are not required to specify the MachineName if you are connecting to a log on the local computer. If you do not specify the MachineName, the local computer (".") is assumed.

Use WriteEvent and WriteEntry to write events to an event log. You must specify an event source to write events; you must create and configure the event source before writing the first entry with the source.

Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configuration. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail. You can configure a new source using an EventLogInstaller, or using the CreateEventSource method. You must have administrative rights on the computer to create a new event source.

You can create an event source for an existing event log or a new event log. When you create a new source for a new event log, the system registers the source for that log, but the log is not created until the first entry is written to it.

The source must be unique on the local computer; a new source name cannot match an existing source name or an existing event log name. Each source can write to only one event log at a time; however, your application can use multiple sources to write to multiple event logs. For example, your application might require multiple sources configured for different event logs or different resource files.

If you change the Source value, the EventLog to which it is registered is closed and all event handles are released.

The source must be configured either for writing localized entries or for writing direct strings. If your application writes entries using both resource identifiers and string values, you must register two separate sources. For example, configure one source with resource files, and then use that source in the WriteEvent method to write entries using resource identifiers to the event log. Then create a different source without resource files, and use that source in the WriteEntry method to write strings directly to the event log using that source.

To change the configuration details of an existing source, you must delete the source and then create it with the new configuration. If other applications or components use the existing source, create a new source with the updated configuration rather than deleting the existing source.

Note

If a source has already been mapped to a log and you remap it to a new log, you must restart the computer for the changes to take effect.

Applies to

See also

  • Log
  • MachineName
  • CreateEventSource
  • DeleteEventSource(String)
  • SourceExists(String)
EventLog.Source Property (System.Diagnostics) (2024)

FAQs

What is the event source in the event log? ›

Each log in the Eventlog key contains subkeys called event sources. The event source is the name of the software that logs the event. It is often the name of the application or the name of a subcomponent of the application if the application is large. You can add a maximum of 16,384 event sources to the registry.

How to diagnose system problems with Event Viewer in Microsoft Windows? ›

Right click on the Start button and select Control Panel > System & Security and double-click Administrative tools. Double-click Event Viewer. Select the type of logs that you wish to review (ex: Application, System)

What is System Event Log 104? ›

Event ID - 104

This event is logged when the log file was cleared. This is a normal condition. No further action is required.

How do I access eventlog? ›

Press the Windows key + R on your keyboard to open the run window. In the run dialog box, type in eventvwr and click OK. In the Event Viewer window, expand the Windows Logs menu. Under the Windows Logs menu, you'll notice different categories of event logs—application, security, setup, system, and forwarded events.

Which is an example of an event source? ›

Examples are an Event Source Connector (which continuously imports data as Event Streams into the Event Streaming Platform from an external system such as a cloud service or a relational database), or an Event Processing Application, such as a Kafka Streams application or the streaming database ksqlDB.

What do you mean by event source? ›

The EventSource interface is web content's interface to server-sent events. An EventSource instance opens a persistent connection to an HTTP server, which sends events in text/event-stream format. The connection remains open until closed by calling EventSource.

How do I find out why my computer crashed in Event Viewer? ›

Open the Event Viewer by pressing Windows + X and selecting Event Viewer. Navigate to Windows Logs > System. Look for any critical errors or warnings around the time of the crash. These entries might provide information about the cause of the crash.

How to repair Windows event log? ›

1. Restart the Windows Event Log Service
  1. Press Win + R to open Run.
  2. Type services. ...
  3. In the right pane, locate and right-click on the Windows Event Log service.
  4. Select Restart and wait for the service to restart.
  5. Close the Services snap-in and try to relaunch Event Viewer to see if the issue is resolved.
Jul 13, 2023

How to clear Event Viewer errors and warnings? ›

The event viewer tool provides a built-in option for clearing event viewer logs. To do this, first open the event viewer by typing eventvwr. msc in the search box or the Run dialog box. Then, in the left pane, expand the Windows Logs folder and select the log you want to clear, such as Application, Security, or System.

What is the system event log 7034? ›

Cause : This event is logged when the service terminated unexpectedly. To resolve this issue, change the recovery actions that the Service Control Manager (SCM) will take when a service fails.

What is the difference between event ID 104 and 1102? ›

Event ID 104: This event ID logs the authentication attempts on a system. Malware may attempt to brute force or guess passwords to gain access to a system, so monitoring for Event ID 104 can help detect suspicious authentication activity. Event ID 1102: This event ID logs the audit log was cleared.

How do I disable system event log? ›

Open the Windows Event Viewer: press Windows R , type eventvwr. msc and press Enter . Scroll down to Application and Service Logs , Microsoft , Windows , WFP . Right-click on a log process and select Disable Log .

How do I see the system event log? ›

The following steps can be taken to check the events logs through the Event Viewer:
  1. Press the Windows key + R on the keyboard to open the Run window.
  2. Enter eventvwr in the Run dialog box and press OK.
  3. Expand the Windows Logs menu in the Event Viewer window.

How to see system event log in cmd? ›

Start Windows Event Viewer through the command line

As a shortcut you can press the Windows key + R to open a run window, type cmd to open a, command prompt window. Type eventvwr and click enter.

How to query Windows event log? ›

First, there are two ways to access the events logged in Windows – through the Event Viewer and using the Get-EventLog / Get-WinEvent cmdlets. The Event Viewer is an intuitive tool which lets you find all the required info, provided you know what to look for.

What is event source in CloudTrail? ›

An event in CloudTrail is the record of an activity in an AWS account. This activity can be an action taken by an IAM identity, or service that is monitorable by CloudTrail.

What is the event source in event-driven programming? ›

Event-driven programming (EDP) is a programming paradigm where external events determine the flow of program execution. These events come in different shapes: user actions (e.g., button clicks, keyboard inputs), system events (like a finished file download), messages from other programs, sensor outputs, etc.

What is the source of event 4776? ›

Event ID 4776 is logged whenever a domain controller (DC) attempts to validate the credentials of an account using NTLM over Kerberos. This event is also logged for logon attempts to the local SAM account in workstations and Windows servers, as NTLM is the default authentication mechanism for local logon.

What is event source in Lambda? ›

An event source mapping is an AWS Lambda resource that reads from an event source and invokes a Lambda function. You can use event source mappings to process items from a stream or queue in services that don't invoke Lambda functions directly.

Top Articles
How to Write Strong Paragraphs
Renew a Certificate
Overton Funeral Home Waterloo Iowa
Www.craigslist Virginia
Mopaga Game
Here are all the MTV VMA winners, even the awards they announced during the ads
Strange World Showtimes Near Cmx Downtown At The Gardens 16
Select Truck Greensboro
123Moviescloud
2024 Non-Homestead Millage - Clarkston Community Schools
Calmspirits Clapper
Dutchess Cleaners Boardman Ohio
Hoe kom ik bij mijn medische gegevens van de huisarts? - HKN Huisartsen
Fear And Hunger 2 Irrational Obelisk
272482061
Letter F Logos - 178+ Best Letter F Logo Ideas. Free Letter F Logo Maker. | 99designs
Sport-News heute – Schweiz & International | aktuell im Ticker
Urban Dictionary: hungolomghononoloughongous
Nhl Wikia
Commodore Beach Club Live Cam
Der Megatrend Urbanisierung
Nurse Logic 2.0 Testing And Remediation Advanced Test
Rural King Credit Card Minimum Credit Score
Rimworld Prison Break
Egizi Funeral Home Turnersville Nj
Sec Baseball Tournament Score
Target Minute Clinic Hours
Getmnapp
Meet the Characters of Disney’s ‘Moana’
Catchvideo Chrome Extension
Jailfunds Send Message
Craftybase Coupon
Possum Exam Fallout 76
Rek Funerals
Mawal Gameroom Download
Wheeling Matinee Results
Craigslist/Phx
Memberweb Bw
Blackstone Launchpad Ucf
Tal 3L Zeus Replacement Lid
Henry County Illuminate
Cbs Fantasy Mlb
Felix Mallard Lpsg
Mytime Maple Grove Hospital
Jamesbonchai
Natasha Tosini Bikini
Watch Chainsaw Man English Sub/Dub online Free on HiAnime.to
Greatpeople.me Login Schedule
Barback Salary in 2024: Comprehensive Guide | OysterLink
Urban Airship Acquires Accengage, Extending Its Worldwide Leadership With Unmatched Presence Across Europe
Buildapc Deals
Ubg98.Github.io Unblocked
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 6165

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.