Skip to main content

Get log

Retrieves connection log data (when in-memory logging is enabled)

Function GetLog(Val Connection, Val AsString = False, Val EventCount = 100) Export

ParameterCLI optionTypeRequiredDescription
Connection-ArbitraryAddIn object with an open connection or port
AsString-BooleanTrue > returns log as a single string, False > as an array
EventCount-NumberNumber of recent events to retrieve. 0 > no limits
Returns

String, Map Of KeyAndValue - Log as a string or a map with the full execution result

Caution

NOCLI: this method is not available in CLI version

1C:Enterprise/OneScript code example
LogFile = GetTempFileName("txt");
LoggingSettings = OPI_ZeroMQ.GetLoggingSettings(True, 100, LogFile);

Port = 5555;
ServerObject = OPI_ZeroMQ.BindPortRep(Port);

If Not OPI_ZeroMQ.IsConnectorObject(ServerObject) Then
Raise OPI_Tools.JSONString(ServerObject);
EndIf;

Address = "tcp://127.0.0.1:5555";
Connection = OPI_ZeroMQ.CreateConnectionReq(Address, LoggingSettings);

If Not OPI_ZeroMQ.IsConnectorObject(Connection) Then
Raise OPI_Tools.JSONString(Connection);
EndIf;

Message = StrTemplate("ZMQ_LOG_%1", Format(CurrentDate(), "DF=yyyyMMddhhmmss"));
Data = GetBinaryDataFromString(Message);

OPI_ZeroMQ.SendData(Connection, Data, 3000);
OPI_ZeroMQ.ReceiveData(ServerObject, 3000);

Result = OPI_ZeroMQ.GetLog(Connection);
Result
{
"logs": [
"[2026-05-26 18:38:22.883] Logger initialized",
"[2026-05-26 18:38:22.883] Connecting (REQ/REP) to tcp://127.0.0.1:5555...",
"[2026-05-26 18:38:22.884] Connected (REQ/REP) to tcp://127.0.0.1:5555",
"[2026-05-26 18:38:22.885] Sending 22 bytes (timeout_ms=3000)...",
"[2026-05-26 18:38:22.885] Sent 22 bytes successfully"
],
"result": true,
"returned": 5,
"total": 5
}