Documentation

​
​

Development

User Acquisition

Monetization

Industry

Unity Gaming Services CLI

v1.4

Legacy
​

GitHub Repository

Unity Gaming Services CLI

v1.4

Legacy
​

​
​
Unity Gaming Services CLI
  • Overview
Get started
  • Install the CLI
  • Set up a Common Configuration
  • Get Authenticated
  • Use Your First Command
Base commands
  • Configuration
  • Deploy
  • Environment
  • Fetch
  • Login
  • Logout
  • Status
Deployment definition
  • What is a Deployment Definition
  • Commands for Deployment Definition
  • Excludes
  • Troubleshooting Deployment Definition
Samples
  • CI/CD Pipeline Usage
  • Deploy Samples
  • File Type Associations
  • Redirecting Command Result to File
Troubleshooting
  • Project Roles
  • Unauthorized (Error 403)
CLI Services Documentation
  • Access
  • Cloud Code
  • Cloud Content Delivery
  • Cloud Save
  • Economy
  • Game Server Hosting
  • Leaderboards
  • Lobby
  • Player
  • Remote Config
  • Scheduler
  • Triggers
  1. Overview

Redirecting Command Result to File

Redirect command output and error logs to files for parsing and review.
Read time 2 minutes
Last updated 3 months ago

When running a command, the output is usually visible through the command line interface. However, it's also possible to pipe the command's result and error logs to files.

Recommendation

In order to have parseable and easy to read content in your files, use your command with the
--json
option. This is what a command with the
--json
option might look like:
ugs env list --json

Redirecting a command's result (stdout)

To redirect the result of a command to a file, add
1> res.json
to the end of your command. When your command succeeds, its result will be redirected to the
res.json
file.

Redirecting a command's error output (stderr)

To redirect the error output of a command to a file, add
2> logs.json
to the end of your command. Any error during the execution of your command will end up in the
logs.json
file.

Example

Here's an example of what a command with stdout and stderr piping might look like:
ugs env list --json 1> res.json 2> logs.json

On success, a file named
res.json
is generated. Here's an example of what that file might contain

[ { "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "projectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "name": "production", "isDefault": true, "createdAt": "2022-07-27", "updatedAt": "2022-12-22", "archivedAt": null }]

On failure, a file named
logs.json
is generated. Here's an example of what that file might contain

[ { "Message": "You are not logged into any service account. Please login using the 'ugs login' command.", "Type": "Error" }]

Notes

The file names provided as example
res.json
and
logs.json
are arbitrary names. You may change them to fit your needs.
Although the example uses both result piping and error piping at the same time, you may also use only one or the other.
When using piping, no output will be logged on the command line interface.

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.

  • On this page
    • Recommendation

    • Redirecting a command's result (stdout)

    • Redirecting a command's error output (stderr)

    • Example

      • On success, a file named res.json is generated. Here's an example of what that file might contain

        • On failure, a file named logs.json is generated. Here's an example of what that file might contain

    • Notes