Home Explore Blog CI



nushell

2nd chunk of `book/stdout_stderr_exit_codes.md`
7fa921ba5487f8d47ad08d4197601a6dd19bc7c759e4167000000001000002d2


The log level for output can be set with the `NU_LOG_LEVEL` environment variable:

```nu
NU_LOG_LEVEL=DEBUG nu std_log.nu
```

## File Redirections

If you want to redirect stdout of an external command to a file, you can use `out>` followed by a file path. Similarly, you can use `err>` to redirect stderr:

```nu
cat unknown.txt out> out.log err> err.log
```

If you want to redirect both stdout and stderr to the same file, you can use `out+err>`:

```nu
cat unknown.txt out+err> log.log
```

Note that `out` can be shortened to just `o`, and `err` can be shortened to just `e`. So, the following examples are equivalent to the previous ones above:

Title: File Redirections and Log Levels in Nushell
Summary
Nushell allows redirecting stdout, stderr, or both to files using `out>`, `err>`, and `out+err>` (or their shortened versions `o>` and `e>`). The log level for the messages displayed can be configured using the `NU_LOG_LEVEL` environment variable.