How can I write to a local PI-SDK Message log on a client machine

Discussion created by mjarvis Employee on Apr 27, 2011
Latest reply on Apr 27, 2011 by mjarvis

Hello Team,


I am writing an application which reads data from PI, and I would like the application to write my own custom message when it completes. I have found examples to write to the PI Server, but I don't want to flood the server message log. I can't figure out how to obtain a window into the client message log or the client object. below is how I am writing to the server message log. My _PIServerRef is the PI Server which I am writing to.

Dim ExtendedMessageLog As PISDK.MessageLog2 = Nothing
Dim MessageParams As New PISDKCommon.NamedValues
Dim TemplateParams As New PISDKCommon.NamedValues
Dim NoTemplateParams As New PISDKCommon.NamedValues
Dim MessageTemplate As String = "Date/Time: {0}, ID: {1}, Source: {2} --- {3}"
Dim MessageString As String = String.Empty
Dim ID As Int32

'Get pointer to MessageLog2 Interface
'With a pointer to any interface on the object, you can then call
'QueryInterface to retrieve any other interface the object supports
ExtendedMessageLog = DirectCast(_PIServerRef.MessageLog, PISDK.MessageLog2)

'Build the template parameters
ID = 1
'Templage args for 2065
TemplateParams.Sorted = False
TemplateParams.Add("1", "Example archive type")
TemplateParams.Add("2", "C:\here\myarchive.dat")
TemplateParams.Add("3", 33)
TemplateParams.Add("4", "%")
TemplateParams.Add("5", "42")
TemplateParams.Add("6", Environment.NewLine)
TemplateParams.Add("7", -12001)

'Build extra message parameters        
MessageParams.Add(ExtendedMessageLog.MessageSendNames.Category, "My Category")
MessageParams.Add(ExtendedMessageLog.MessageSendNames.Source1, _
                                                                  "Templated message test")
'MessageParams.Add(ExtendedMessageLog.MessageSendNames.SeverityOverride, _
'                                          PISDK.MsgSeverityConstants.mscError)

'Send it to the PI Server Message Log
ExtendedMessageLog.SendLogMessage(ID, TemplateParams, MessageParams)