Saving nixos trace logs for later consumption, how?

Hello, looking for an idea to deal with warning traces being lost to stdout after running nixos system commands. I would like to find the trace logs created by the operating system.

Nixos-rebuild is a system command of the type. It raises really interesting warnings at times, then subsequent moving instructions it spits out more to console, which usually drowns the original points of interest.

I looked for the trace logs, in var and run, I didn’t see anything related to nixos-rebuild that was recently printed.

Is there a “nixos-baked-in” approach to this, perhaps there’s a setting that I can enable for trace logs to be saved?

Possible solutions

  1. You could Tee upon running the command, or change your shell to wrap tee around the nixos-rebuild, for example.
    Pros: you can review the file after its done Cons: seems too much effort to tee these commands

You could also use systemd-cat to run it, to automatically redirect both stderr and stdout to journal.

1 Like

Why would nixos-rebuild output be “lost” to stdout? What’s stdout attached to here in this scenario? I assume it’s not a pty?

Something like 2>/path/to/log?

When I used the word “lost”, this was a false statement. It isn’t lost in the sense that it’s cleared from a buffer. I meant to say lost from my vision and extremely difficult to scroll up with hundreds of lines, at times.

Sure.

I was wondering if Nixos had a “enable logs” that could put it in a file for me?