How to print variable and exit code data in the deployment logs

How to print the value of Substitution variable and Deployment error details(Success and failure) in the logs using varibales

To print the variable and their value used in deployment, I used “OctopusPrintVariables” set to true.

But it print all the variables.
I require only the user define variables in the project to be printed with value, please advice


If you need to print only some of the variables, you can do that in a script step. The OctopusPrintVariables option is intended to assist in debugging problems.

I hope this helps,