QuickOPC User's Guide and Reference
LogEntry Event (EasyUAClient)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > EasyUAClient Class : LogEntry Event
Raised for loggable entries originating in the OPC-UA client engine and the EasyUAClient component.
Syntax
'Declaration
 
Public Event LogEntry As LogEntryEventHandler
'Usage
 
Dim instance As EasyUAClient
Dim handler As LogEntryEventHandler
 
AddHandler instance.LogEntry, handler
public event LogEntryEventHandler LogEntry
public:
event LogEntryEventHandler^ LogEntry
Event Data

The event handler receives an argument of type LogEntryEventArgs containing data related to this event. The following LogEntryEventArgs properties provide information specific to this event.

PropertyDescription
The application-specific subcategory associated with the message.  
Default value of the Timestamp property.  
Entry type. One of the LogEntryType values.  
The application-specific identifier for the event.  
The message text.  
An array of bytes that holds the binary data associated with the entry.  
The name of the event source.  
Date and time of the log entry message. In UTC.  
Date and time of the log entry message. In UTC, as double-precision floating-point number that contains an OLE Automation date.  
Date and time of the log entry message. In local time.  
Date and time of the log entry message. In local time, as double-precision floating-point number that contains an OLE Automation date.  
Example
// This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component.

using System;
using OpcLabs.BaseLib.Instrumentation;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    class LogEntry
    {
        public static void Main1()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Hook static events
            EasyUAClient.LogEntry += EasyUAClientOnLogEntry;

            try
            {
                // Do something - invoke an OPC read, to trigger some loggable entries.
                var client = new EasyUAClient();
                try
                {
                    client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853");
                }
                catch (UAException uaException)
                {
                    Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                    return;
                }

                Console.WriteLine("Processing log entry events for 1 minute...");
                System.Threading.Thread.Sleep(60 * 1000);

                Console.WriteLine("Finished.");
            }
            finally
            {
                // Unhook static events
                EasyUAClient.LogEntry -= EasyUAClientOnLogEntry;
            }
        }

        // Event handler for the LogEntry event. It simply prints out the event.
        private static void EasyUAClientOnLogEntry(object sender, LogEntryEventArgs logEntryEventArgs)
        {
            Console.WriteLine(logEntryEventArgs);
        }
    }
}
' This example demonstrates the loggable entries originating in the OPC-UA client engine and the EasyUAClient component.

Imports OpcLabs.BaseLib.Instrumentation
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Friend Class LogEntry
        Public Shared Sub Main1()

            Dim endpointDescriptor As UAEndpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            ' Hook static events
            AddHandler EasyUAClient.LogEntry, AddressOf EasyUAClientOnLogEntry

            Try
                ' Do something - invoke an OPC read, to trigger some loggable entries.
                Dim client = New EasyUAClient()
                Try
                    client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853")
                Catch uaException As UAException
                    Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                    Exit Sub
                End Try

                Console.WriteLine("Processing log entry events for 1 minute...")
                Threading.Thread.Sleep(60 * 1000)

                Console.WriteLine("Finished.")
            Finally
                ' Unhook static events
                RemoveHandler EasyUAClient.LogEntry, AddressOf EasyUAClientOnLogEntry
            End Try

        End Sub


        ' Event handler for the LogEntry event. It simply prints out the event.
        Private Shared Sub EasyUAClientOnLogEntry(ByVal sender As Object, ByVal logEntryEventArgs As LogEntryEventArgs)
            Console.WriteLine(logEntryEventArgs)
        End Sub
    End Class
End Namespace
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2012 R2, Windows Server 2016; .NET: Linux, macOS, Microsoft Windows

See Also