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-03-25 09:34:14.338] Binding to port 9877...",
"[2026-03-25 09:34:14.338] Successfully bound to port 9877",
"[2026-03-25 09:34:14.338] Listener task started",
"[2026-03-25 09:34:14.339] New connection accepted: 7a3efe30-6178-470e-8a9e-ad95545116b1 from 127.0.0..."
],
"result": true,
"returned": 4,
"total": 4
}