Skip to content

Log (custom log line)

ts
function Log(line: any): void;

The Log function writes a custom entry to the Syncplify Server! log. While you can pass any value (string, number, object, etc.), it is most common to log a string or a stringified object.

Unlike JavaScript's console.log(), SyncJS's Log() always works—regardless of context (synchronous or asynchronous)—and does not require a console to be available. Your log entry will be sent to the currently configured logging destination (file, syslog, stdout, etc.) as determined by your server's settings.

TIP

Use Log() for debugging, auditing, or recording important events in your scripts. Logging objects or arrays? Use JSON.stringify() for readable output.

WARNING

The Log function is often misunderstood: it does not print to a terminal or browser console, but writes to the server's log. Always check your server's log configuration to know where your entries will appear.

Parameters

NameTypeDescription
lineanyThe value to log. Strings, numbers, objects, etc.

Returns

This function does not return a value.

Example

ts
Log('Hello, world!');

var some_data = { user: 'alice', action: 'login' };
Log(JSON.stringify(some_data));

Severity-level methods

In addition to the bare Log(msg) call (which logs at Info level), the Log object exposes five severity-level methods. Use these when you want precise control over the log level of each entry.

ts
Log.Trace(msg: any): void;
Log.Debug(msg: any): void;
Log.Info(msg: any):  void;
Log.Warn(msg: any):  void;
Log.Error(msg: any): void;

All five methods behave identically to Log() except for the severity level they emit. The level filtering applied to these entries is controlled by your server's log configuration.

Example

ts
Log.Debug('Starting file processing loop');

for (var i = 0; i < files.length; i++) {
  Log.Trace('Processing file: ' + files[i].Name);
  if (!CopyFile(files[i].Name, '/var/archive/')) {
    Log.Error('Failed to copy file: ' + files[i].Name);
  }
}

Log.Info('File processing complete');

TIP

Reserve Log.Trace and Log.Debug for detailed diagnostic output that you would normally only enable when troubleshooting. Use Log.Warn for non-fatal anomalies and Log.Error for failures that require attention.