Trace
-----

Starts logging all plugin calls to a text file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Trace](component_Trace.md) | [2.4](newinversion24.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Trace" { ; Path; Append } ) 

**MBS**( **"Trace";** /\* Starts logging all plugin calls to a text file. \*/  
**$Path**; /\* Optional; The native file path to the log file.e.g. "/Users/name/Desktop/trace.txt" \*/   
**$Append**) /\* Optional; Whether to append or create new file.  
Pass 1 to append or 0 (default) for new file.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The native file path to the log file. | "/Users/name/Desktop/trace.txt" | Optional |
| Append | Whether to append or create new file.   Pass 1 to append or 0 (default) for new file. | 1 | Optional |

### Result

Returns "OK" on success.

### Description

Starts logging all plugin calls to a text file.  
If you pass a path, debug messages are written to the file. Else the plugin writes to debug console. See Console.app on Mac or DebugView on Windows.  
See also [Trace.Off](TraceOff.md) and [Trace.SetErrorsOnly](TraceSetErrorsOnly.md).  
  
On Linux, if no path is provided, the log output will go to stderr, which is usually redirected by our plugin to /FileMaker/FileMaker Server/Logs/ folder. The log files are StdErrWeb.log and StdOutWeb.log for Web Direct and StdErrServerScripting.log and StdOutServerScripting.log for normal scripting (the names may change in different plugin versions).  
  
On Windows with a FileMaker Server, you can see debug messages in DebugView if you run DebugView application as admin and enable global Win32 listening.  
For FileMaker Server on macOS you can see messages in /Library/FileMaker Server/Logs/stderr file.  
  
On Windows the log file is UTF-16 with BOM and CRLF as line endings. On macOS, Linux and iOS, you get an UTF-8 file with BOM and LF line endings.  
  
See [Trace.GetErrorsOnly](TraceGetErrorsOnly.md), [Trace.GetWithTimes](TraceGetWithTimes.md), [Trace.SetErrorsOnly](TraceSetErrorsOnly.md) and [Trace.SetWithTimes](TraceSetWithTimes.md) to set options.  
  
Added tracing of SQL commands for our [SQL](component_SQL.md) functions for v13.1. The SQL may be truncated around 4000 characters to limit how much text we log.  
  
Log files paths for MBS Plugin on Linux:  
| /opt/FileMaker/FileMaker Server/Logs/StdErrServerScripting.log | Error log for Server Scripting |
|---|---|
| /opt/FileMaker/FileMaker Server/Logs/StdOutServerScripting.log | Output log for Server Scripting |
| /opt/FileMaker/FileMaker Server/Logs/StdErrDataAPI.log | Error log for Data API |
| /opt/FileMaker/FileMaker Server/Logs/StdOutDataAPI.log | Output log for Data API |
| /opt/FileMaker/FileMaker Server/Logs/StdErrWeb.log | Error log for Web Direct |
| /opt/FileMaker/FileMaker Server/Logs/StdOutWeb.log | Output log for Web Direct |

  
Other OS have similar paths. You may find .old files with previous log files, so you can review the old log after a crash.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Log plugin calls to console:

 MBS ( "Trace" )  
Log plugin calls to desktop on Windows:

 MBS ( "Trace"; MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ); "trace.txt" ))  
Log plugin calls to temp folder on Mac or Linux:

 MBS ( "Trace"; "/tmp/MBS Plugin Log.txt")  
Log to log file on desktop:

 Set Variable \[$TracePath ; Value:MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ); "trace.txt" )\]  
Set Variable \[$r ; Value:MBS ("Trace"; $TracePath )\]  
Setup logging on server with multiple log files and times:

 Set Variable \[ $r ; Value: MBS ( "[Trace.SetWithTimes](TraceSetWithTimes.md)"; 1) \]  
Set Variable \[ $r ; Value: MBS ( "[Trace.SetServerLogPath](TraceSetServerLogPath.md)"; "/Library/FileMaker Server/Logs/") \]  
Set Variable \[ $r ; Value: MBS ( "Trace") \]  
### See also

- [Folders.UserDesktop](FoldersUserDesktop.md)
- [IsRegistered](IsRegistered.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Register](Register.md)
- [Trace.GetErrorsOnly](TraceGetErrorsOnly.md)
- [Trace.Path](TracePath.md)
- [Trace.SetErrorsOnly](TraceSetErrorsOnly.md)
- [Trace.SetServerLogPath](TraceSetServerLogPath.md)
- [Trace.SetWithTimes](TraceSetWithTimes.md)

### Release notes

- **Version 14.3**
    - Changed [trace](https://www.mbsplugins.eu/Trace.shtml) function to not log the password for a [Files.Mount](https://www.mbsplugins.eu/FilesMount.shtml) call.
- **Version 14.1**
    - Changed [Trace](https://www.mbsplugins.eu/Trace.shtml) function to not shorten texts with CURL.DebugMessages or returned error.
- **Version 13.1**
    - Fixed a crash in [trace](https://www.mbsplugins.eu/Trace.shtml) function.

### Blog Entries

- [MBS Plugin 15.5 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-11-18/MBS_Plugin_155_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [Use Perform Script on Server inside Data API script](https://www.mbsplugins.de/archive/2023-12-11/Use_Perform_Script_on_Server_i/monkeybreadsoftware_blog_filemaker)
- [MBS @ FMTraining.TV - Debugging your FileMaker Servers with the MonkeyBread Plug-in](https://www.mbsplugins.de/archive/2023-07-23/MBS_@_FMTrainingTV_-_Debugging/monkeybreadsoftware_blog_filemaker)
- [How to use Trace](https://www.mbsplugins.de/archive/2023-07-15/How_to_use_Trace/monkeybreadsoftware_blog_filemaker)
- [MBS @ FMTraining.TV - What’s New in the FileMaker MonkeyBread Plug-in - 13.2 Release](https://www.mbsplugins.de/archive/2023-05-21/MBS_@_FMTrainingTV_-_What’s_/monkeybreadsoftware_blog_filemaker)
- [Install a FileMaker 2023 Server in Linux in Parallels Desktop](https://www.mbsplugins.de/archive/2023-05-10/Install_a_FileMaker_2023_Serve/monkeybreadsoftware_blog_filemaker)
- [Using JavaScript with WebKit on FileMaker Server on Linux](https://www.mbsplugins.de/archive/2023-03-05/Using_JavaScript_with_WebKit_o/monkeybreadsoftware_blog_filemaker)
- [Additional iOS Script Triggers](https://www.mbsplugins.de/archive/2022-12-24/Additional_iOS_Script_Triggers/monkeybreadsoftware_blog_filemaker)
- [Install MBS Plugin on a FileMaker Server](https://www.mbsplugins.de/archive/2022-02-20/Install_MBS_Plugin_on_a_FileMa/monkeybreadsoftware_blog_filemaker)
- [Trigger scripts via plugin and fmplugin extended privilege](https://www.mbsplugins.de/archive/2021-08-21/Trigger_scripts_via_plugin_and/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2022, Seite 18](https://filemaker-magazin.de/neuigkeit/4174-Appetithappen-FMM_202202)
- [Ausgabe 2/2017, Seite 39](https://filemaker-magazin.de/neuigkeit/3930-Appetithappen-FMM_201702)

This function is free to use.

Created 18th August 2014 , last changed 3th May 2025

  
[TouchBar.Visible](TouchBarVisible.md) - [Trace.AreErrorNotificationsEnabled](TraceAreErrorNotificationsEnabled.md)

[HTML Version](Trace.shtml)