Use logging tools in the Salesforce CLI to monitor deployed functions. Receive a list of deployed functions and stream logs from running functions.
Get List of Deployed Functions
Display a list of your deployed functions for easy tracking.
View all your environments and their aliases:
sf env list
Example output:
Salesforce Orgs
=======================================================================================================================================
| Aliases Username Org ID Instance Url Auth Method Config
| ─────── ──────────────────────────────────── ────────────────── ────────────────────────────────────────── ─────────── ──────────────
| rodri.s+functions@salesforce.com 234123412341234123 https://xxx000xxxx001234.my.salesforce.com web target-dev-hub
Scratch Orgs
========================================================================================================================================================
| Aliases Username Org ID Instance Url Auth Method Config
| ───────────────── ───────────────────────────── ────────────────── ──────────────────────────────────────────────────────────── ─────────── ──────────
| MyScratchOrgAlias test-12341234123a@example.com XX010XXXX00abCDEFG https://mycompany.scratch.my.salesforce.com web target-org
Compute Environments
===========================================================================================================================================
| Alias Project Name Connected Org Alias Connected Org Id Compute Environment Name Compute Environment Id
| ──────────── ───────────────── ─────────────────── ────────────────── ────────────────────────────── ────────────────────────────────────
| MyComputeEnv MyFunctionProject MyScratchOrgAlias XX010XXXX00abCDEFG myfunct-xx010xxxx00abcdefg-792 7gh6sda2-8s5n-2j23-wj3e-dfdn1i2313fc
| MyFunctionProject 00D3F000000bJEHUA2 myfunct-00d3f000000bjehua2-712 kj3k6j32-3me3-29ck-bd21-e1i9219jd22a
| MyFunctionProject 00D54000000dXeOEAU myfunct-00d54000000dxeoeau-469 sdka231k-0e3e-210j-a72a-aqwkeqwkwd08
Display details about a specific compute environment:
sf env display -e MyComputeEnv
Example output:
Key Value
────────────────────── ────────────────────────────────────
Alias MyComputeEnv
Environment Name myfunct-XX010XXXX00abCDEFG-2
Project MyFunctionProject
Created Date 2022-02-24T23:14:04Z
Connected Org Id XX010XXXX00abCDEFG
Connected Org Status Active
Connected Org Alias MyScratchOrgAlias
Connected Org Username test-1234XXX@example.com
Functions
App ID XXXX0000-XXXX-0000-XXXX-XXXX0000XXXX
Space ID 0000XXXX-0000-XXXX-0000-0000XXXX0000
Stream Function Logs
Salesforce Functions has logging tools to monitor, debug, and analyze how your deployed functions are running at the compute environment level. Logged activity for all functions deployed to a compute environment is captured in the same log. Filter log data by function, date and time, or any other logline field.
note: Any Apex logs created from your Apex code that invokes a Function isn't captured in compute environment logs. For dealing with log information from Apex code, see Working with Apex Debug Logs.
Start a Function Log
tip: Environment logs aren't buffered and logline outputs occur after the command is executed. Start tailing the environment log in a separate shell before the function is invoked to capture log details.
sf env log tail -e MyComputeEnvironment
Example output:
2022-02-24T23:14:05.331411+00:00 app[api]: Release v1 created by user 00d5f000006ognfeao-test@herokumanager.com
2022-02-24T23:14:05.331411+00:00 app[api]: Initial release by user 00d5f000006ognfeao-test@herokumanager.com
2022-02-24T23:14:05.527549+00:00 app[api]: Release v2 created by user 00d5f000006ognfeao_0055f000006voq8aak@evergreeninternal.herokai.com
2022-02-24T23:14:05.527549+00:00 app[api]: Enable Logplex by user 00d5f000006ognfeao_0055f000006voq8aak@evergreeninternal.herokai.com
Log information starts to output to the current shell. To stop capturing logs, quit the process by using Ctrl-C in your shell.
The log tail process will terminate after 1 hour of inactivity. Reuse sf env log tail to continue logging.
Run sf env log tail -e MyComputeEnvironment and invoke your function.
Example log output for an invoked function:
2021-11-01T19:57:21.709786+00:00 app[jsfunction-74d7b5b75c-8xvxb]: name=functionLogger hostname=jsfunction-74d7b5b75c-8xvxb pid=25 worker=1 level=30 msg="started function worker 1" time=2021-11-01T19:57:21.709Z v=0
2021-11-01T19:57:21.916912+00:00 app[jsfunction-74d7b5b75c-8xvxb]: name=functionLogger hostname=jsfunction-74d7b5b75c-8xvxb pid=31 worker=2 level=30 msg="started function worker 2" time=2021-11-01T19:57:21.916Z v=0
2021-11-01T19:57:21.609641+00:00 app[jsfunction-74d7b5b75c-f2tfm]: name=functionLogger hostname=jsfunction-74d7b5b75c-f2tfm pid=24 worker=1 level=30 msg="started function worker 1" time=2021-11-01T19:57:21.608Z v=0
2021-11-01T19:57:21.923530+00:00 app[jsfunction-74d7b5b75c-f2tfm]: name=functionLogger hostname=jsfunction-74d7b5b75c-f2tfm pid=30 worker=2 level=30 msg="started function worker 2" time=2021-11-01T19:57:21.922Z v=0