Skip to main content

Get log

Retrieves server log data (with logging to memory enabled)

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

ParameterCLI optionTypeRequiredDescription
ServerObject-ArbitraryObject of running server component
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
LaunchPort = 9877;
LogFile = GetTempFileName("txt");
LoggingSettings = OPI_TCP.GetLoggingSettings(True, 100, LogFile);
ServerObject = OPI_TCP.StartServer(LaunchPort, , LoggingSettings);

// Connect to running server
ConnectionAddress = "127.0.0.1:9877";
ClientObject = OPI_TCP.CreateConnection(ConnectionAddress);
If Not OPI_TCP.IsClientObject(ClientObject) Then
Raise OPI_Tools.JSONString(ClientObject);
EndIf;

Result = OPI_TCP.GetLog(ServerObject);
Result
{
"logs": [
"[2026-05-02 11:05:53.665] Binding to port 9877...",
"[2026-05-02 11:05:53.666] Successfully bound to port 9877",
"[2026-05-02 11:05:53.666] Listener task started",
"[2026-05-02 11:05:53.666] New connection accepted: bb4d5228-36fa-4e79-8387-a5e4bbd6b101 from 127.0.0..."
],
"result": true,
"returned": 4,
"total": 4
}