{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":21081,"path":"integrate-applications/integration-hub/configure-logging-powershell-step.md","title":"Configure logging for the PowerShell step","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure logging for the PowerShell step\n\nAdd log messages to the scripts in your PowerShell step. Use log levels for improved logging and debugging.\n\n## Before you begin\n\nTo add log messages to your script, you will need to use the Write-SNCLog function. This function is defined in the IH\\\\Logging.psm1 module. Use PSScript.ps1 to import this module so inline scripts have access to Write-SNCLog. For more information, see [MID Server PowerShell files](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/mid-server-powershell-files.md).\n\nRole required: admin\n\n## Procedure\n\n1.  Navigate to **All** &gt; **MID Server** &gt; **Properties**.\n\n2.  Set **mid.property.powershell.log\\_info** to **true**.\n\n    This property enables or disables logging. For more information, see [PowerShell log property](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/powershell-log-property.md).\n\n3.  Set **mid.property.powershell.ih.log\\_level** to the desired log level.\n\n    The log level specifies the threshold required to log a message. Messages are logged at the specified level or higher. For example, if this property is set to WARN, then messages with a level of WARN or ERROR are logged. Messages with a level of INFO, DEBUG, or TRACE are not logged. The levels, listed from low to high, are:\n\n    -   TRACE\n    -   DEBUG\n    -   INFO\n    -   WARN\n    -   ERROR\n    The default value is INFO.\n\n4.  Configure a system property so that you can view the logs in the instance.\n\n    1.  Navigate to **All** &gt; **Process Automation** &gt; **Flow Designer** &gt; **Properties**.\n\n    2.  Find **Specify the log level of system log entries to replicate to the flow log. The system only replicates log entries of the specified level or higher** and set it to **INFO** or **DEBUG**.\n\n    After the you build and execute the PowerShell script, the logs are available in the MID agent log. Configuring this property also enables you to view them directly in the instance.\n\n    This step sets the **com.glide.hub.flow\\_engine.listener\\_trace.threshold** property. It replicates the logs to the Flow engine log entries \\[sys\\_flow\\_log\\] table.\n\n5.  In your PowerShell script, add log messages and levels with the Write-SNCLog function.\n\n<table id=\"table_pxf_3lj_dtb\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nWrite-SNCLog function\n\n</td><td>\n\nLog a message for the PowerShell step. Write-SNCLog has two parameters, **-Level** and **-Message**. Both parameters are required, but the parameter names are not. If the names are omitted, the position is used to determine the level and message. Examples: -   `Write-SNCLog -Level WARN -Message \"log warning\"`\n-   `Write-SNCLog WARN \"log warning\"`\nBoth of these examples log `WARN: log warning`.\n\n</td></tr><tr><td>\n\n**-Level** parameter\n\n</td><td>\n\nSpecify the level for the log message. Valid values are:-   ERROR\n-   WARN\n-   INFO\n-   DEBUG\n-   TRACE\nThis parameter is required.\n\n</td></tr><tr><td>\n\n**-Message** parameter\n\n</td><td>\n\nSpecify the message to log. Entered as a string. This parameter is required.\n\n</td></tr></tbody>\n</table>6.  Continue building your action or flow, then test and run it.\n\n\n## What to do next\n\nThe new logs are available in the MID agent log and can be downloaded from the MID Server. For more information, see [Download the MID Server files](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/t_DownloadMIDServerFiles.md).\n\nIf you set the system property to view the logs in the instance, you can see them in the **Flow engine log entries** tab of the Flow engine context record. For more information, see Flow execution details.\n\n**Parent Topic:**[PowerShell step](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/integrate-applications/integration-hub/powershell-step-action-designer.md)\n\n**Related topics**  \n\n\n[Test a credential for the PowerShell step]()\n\n"}}