इसके माध्यम से साझा किया गया


Manage log files

Important

This is the Azure Sphere (Legacy) documentation. Azure Sphere (Legacy) is retiring on 27 September 2027, and users must migrate to Azure Sphere (Integrated) by this time. Use the Version selector located above the TOC to view the Azure Sphere (Integrated) documentation.

The Azure Sphere CLI allows you decide if you want to include diagnostic and configuration information from your computer, the cloud, and the attached Azure Sphere device in a log file. You can either enable or disable logging using the CLI for a specific session or permanently by setting the environment variable.

Note

  • This feature is not supported in Azure Sphere classic CLI.
  • By default, if the environment variable is not set, logging is disabled.

Configure logging in the CLI

Logging is configured by setting the environment variable AZSPHERE_FILE_LOGGING_DISABLED. When logging is enabled, a log file is created in the C:\Users<user>.azsphere\logs directory on Windows and ~/.azsphere/logs on Linux. Additionally, the information is also included in the .zip file created when you run the azsphere get-support-data command.

Example

Here's an example to configure logging using the CLI:

Note

The preferences you set apply only to the current CLI session you are in and is not persistent across sessions. To permanently set your preference, refer to the documentation provided for your operating system.

The supported values are:

  • 0 to enable logging
  • 1 to disable logging
  • If not set, logging is disabled

Windows Command Prompt

To enable logging:

set AZSPHERE_FILE_LOGGING_DISABLED=0

To disable logging:

set AZSPHERE_FILE_LOGGING_DISABLED=1

To clear setting:

set AZSPHERE_FILE_LOGGING_DISABLED=

To view the value of the environment variable, type set AZSPHERE_FILE_LOGGING_DISABLED in the command prompt.

Windows PowerShell

You can run the command from Windows Command Prompt and Windows PowerShell:

To enable logging:

$env:AZSPHERE_FILE_LOGGING_DISABLED=0

To disable logging:

$env:AZSPHERE_FILE_LOGGING_DISABLED=1

To clear setting:

Remove-Item -Path Env:AZSPHERE_FILE_LOGGING_DISABLED

To view the value of the environment variable, type dir env: in PowerShell, and locate AZSPHERE_FILE_LOGGING_DISABLED in the list.