Good Afternoon,
Wondering if someone can help me with this:
What i am trying to achieve is writing a full event log entry including log type and so on to a remote event log on Win2k8 server. I have already setup the SDDL for this for the correct SID so permissions are not an issue.
My issue here is that if i use the basic
EventLog.WriteEntry
message it works fine and the remote machine receives the request however when i try and enter a full entry it produces a warning of:
Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated
Which subsequently does not populate the event log on the remote machine.
Logging on the local machine is just not an option simply put they are wokring on TFTP images which are reset upon restart of the device and thus will lose any history.
This Works Fine:
MyEvtLog.WriteEntry(Message)
My code so far:
Private MyEvtLog As EventLog
Dim Source As String = "My Product"
Dim Log As String = "Company Software"
Dim eMachine As String = "MyMachineName.Domain.Local"
Enum LoggingSeverity
Informational = 1
Warning = 2
Severe = 3
Critical = 4
End Enum
Sub New()
Try
MyEvtLog = New EventLog(Log, eMachine, Source)
Catch ex As Exception
End Try
End Sub
Private Sub Logging_LoggingRequest(Severity As LoggingSeverity, DateTime As String, Message As String, ByVal Document As String, ByVal Routine As String)
Try
Dim LogDataEntry As String =
"<ComputerInfo>
<Username>{0}</Username>
<Computer>{1}</Computer>
<Domain>{2}</Domain>
</ComputerInfo>
<ErrorDetails>
<Severity>{3}</Severity>
<Timestamp>{4}</Timestamp>
<Document>{5}</Document>
<Routine>{6}</Routine>
<Message>{7}</Message>
</ErrorDetails>"
LogDataEntry = String.Format(LogDataEntry, Environment.UserName, Environment.MachineName, Environment.UserDomainName, Severity, DateTime, Document, Routine, Message)
Select Case Severity
Case LoggingSeverity.Informational
MyEvtLog.WriteEntry(Source, LogDataEntry, EventLogEntryType.Information, 0)
Case LoggingSeverity.Warning
MyEvtLog.WriteEntry(Source, LogDataEntry, EventLogEntryType.Warning, 0)
Case LoggingSeverity.Severe
MyEvtLog.WriteEntry(Source, LogDataEntry, EventLogEntryType.FailureAudit, 0)
Case LoggingSeverity.Critical
MyEvtLog.WriteEntry(Source, LogDataEntry, EventLogEntryType.Error, 0)
End Select
End Try
End Sub
Certainly would appreciate some info on writing a full event log entry to a remote machine, as currently this doesnt work but i need to be able to determine errors or warnings.
Thanks
dave