Parity Logs – How to Make Parity Write Logs for Monitoring

logsmonitoringparity

I'm running a parity supernode, recently switched from geth because parity seems to perform much better, even in archive mode.

To log the standard output of geth, I used to run:

geth [options] console 2>>/tmp/geth.log

I tried to run similar command for parity, but it wont log the standard out.

 ~ $ parity --help | grep -A1 log
  -l --logging LOGGING     Specify the logging level. Must conform to the same
                           format as RUST_LOG.

Natively, parity allows to set a logging level. But how can I make parity actually write logs?

Best Answer

Send Stderr And Stdout To A Log File

If you want to overwrite the log file each time you start your command:

parity [options] > /tmp/parity.log 2>&1

If you want to append to your log file each time you start your command:

parity [options] >> /tmp/parity.log 2>&1



Send Stderr And Stdout To Separate Log Files While Viewing Output

And if you want to log stderr and stdout into separate log files while viewing the output on your console:

parity [options] > >(tee stdout.log) 2> >(tee stderr.log >&2)

Reference How do I write stderr to a file while using “tee” with a pipe?.

If you want to create a script file to run this command, you will have to use #!/bin/bash (instead of #!/bin/sh) in the first line of the file as this redirection is bash specific:

#!/bin/bash

cd $HOME/Parity

parity [options] > >(tee stdout.log) 2> >(tee stderr.log >&2)

Save the above into $HOME/bin/runParity, chmod 700 $HOME/bin/runParity and your can then type runParity (or $HOME/bin/runParity) to start it.

Related Topic