Monitor Deployed Functions

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:

1sf env list

Example output:

1Salesforce Orgs
2=======================================================================================================================================
3| Aliases Username                             Org ID             Instance Url                               Auth Method Config
4| ─────── ──────────────────────────────────── ────────────────── ────────────────────────────────────────── ─────────── ──────────────
5|         rodri.s+functions@salesforce.com 234123412341234123 https://xxx000xxxx001234.my.salesforce.com web         target-dev-hub
6
7Scratch Orgs
8========================================================================================================================================================
9| Aliases           Username                      Org ID             Instance Url                                                 Auth Method Config
10| ───────────────── ───────────────────────────── ────────────────── ──────────────────────────────────────────────────────────── ─────────── ──────────
11| MyScratchOrgAlias test-12341234123a@example.com XX010XXXX00abCDEFG https://mycompany.scratch.my.salesforce.com                  web         target-org
12
13Compute Environments
14===========================================================================================================================================
15| Alias        Project Name      Connected Org Alias Connected Org Id   Compute Environment Name       Compute Environment Id
16| ──────────── ───────────────── ─────────────────── ────────────────── ────────────────────────────── ────────────────────────────────────
17| MyComputeEnv MyFunctionProject MyScratchOrgAlias   XX010XXXX00abCDEFG myfunct-xx010xxxx00abcdefg-792 7gh6sda2-8s5n-2j23-wj3e-dfdn1i2313fc
18|              MyFunctionProject                     00D3F000000bJEHUA2 myfunct-00d3f000000bjehua2-712 kj3k6j32-3me3-29ck-bd21-e1i9219jd22a
19|              MyFunctionProject                     00D54000000dXeOEAU myfunct-00d54000000dxeoeau-469 sdka231k-0e3e-210j-a72a-aqwkeqwkwd08

Display details about a specific compute environment:

1sf env display -e MyComputeEnv

Example output:

1Key                    Value
2 ────────────────────── ────────────────────────────────────
3 Alias                  MyComputeEnv
4 Environment Name       myfunct-XX010XXXX00abCDEFG-2
5 Project                MyFunctionProject
6 Created Date           2022-02-24T23:14:04Z
7 Connected Org Id       XX010XXXX00abCDEFG
8 Connected Org Status   Active
9 Connected Org Alias    MyScratchOrgAlias
10 Connected Org Username test-1234XXX@example.com
11 Functions
12 App ID                 XXXX0000-XXXX-0000-XXXX-XXXX0000XXXX
13 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.

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.

Note

Start a Function Log 

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.

Tip

1sf env log tail -e MyComputeEnvironment

Example output:

12022-02-24T23:14:05.331411+00:00 app[api]: Release v1 created by user 00d5f000006ognfeao-test@herokumanager.com
22022-02-24T23:14:05.331411+00:00 app[api]: Initial release by user 00d5f000006ognfeao-test@herokumanager.com
32022-02-24T23:14:05.527549+00:00 app[api]: Release v2 created by user 00d5f000006ognfeao_0055f000006voq8aak@evergreeninternal.herokai.com
42022-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:

12021-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
22021-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
32021-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
42021-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

Product Retirement Announcement

Salesforce Functions is no longer available for purchase or renewal. To preserve the capabilities that Salesforce Functions provided to your org, deploy an alternative solution before your existing order term ends. See Salesforce Functions Retirement for more information on migrating your functions. Contact your Salesforce Account Executive for more information on Heroku.