The Domain.com network contains an application server named Certkiller -SR07.
You have been asked to profile a business application that can be accessible using the Event Log API.
You want to achieve this by creating a custom event log on Certkiller -SR07.
What should you do?
A.
Use the following code:
EventLog.CreateEventSource(“Application1”, “Profile”, “Certkiller -SR07”);
B.
Use the following code:
EventLog.CreateEventSource(“Application1”, “Profile”);
C.
Use the following code:
EventSourceCreationData sourceData = new EventSourceCreationData(“Application1”, “Profile”);
sourceData.MachineName = “Certkiller -SR07”;
EventLog.CreateEventSource (sourceData);
D.
Use the following code:
EventSourceCreationData sourceData = new EventSourceCreationData (“Application1”, “Profile”);
EventLog.CreateEventSource(sourceData);
Explanation:
This code instantiates an EventSourceCreationData object, sets the MachineName property of the
EventSourceCreationData object, and invokes the CreateEventSource method, passing the EventSourceCreationData object
as an argument, to create the custom event log.
The EventSourceCreationData object is used to configure a new event log source. You can then pass the EventSourceCreationData object to the CreateEventSource method of an EventLog
to register the event log source and corresponding event log so that you can write entries to it.
The EventSourceCreationData object’s constructor accepts two String arguments: Source and Log.
The Source argument specifies the event source, and the Log argument specifies the name of the event log.
After creating an instance of EventSourceCreationData, you can set the EventSourceCreationData object’s properties to further configure the event source.
The MachineName property represents the computer on which you want to create the event source.
In this scenario, you create a new EventSourceCreationData object named sourceData and then set its MachineName property to Certkiller -SR07. Then, you call the CreateEventSource method, passing the method sourceData. This creates an event log source on the computer named Certkiller -SR07.
Incorrect Answers:
A: The CreateEventSource method that takes three String arguments is obsolete in the .NET 2.0 Framework.
B, D: Both of these code fragments would create an event log on the local computer by default,
but the scenario states that you should explicitly specify the machine name because the computer on which the code is running is unknown.
I choose C