Collecting logs with runbook

I am trying to download logs from deployment targets using Runbook. I have made a runbook with the Collect Artifacts step template wich i got working with hardcoding the Artifact Path. But i would like this path to be dynamic for the latest release of the project, but how can i achieve that?
I tried with the #{Octopus.Tentacle.PreviousInstallation.OriginalInstalledPath} and the #{Octopus.Action.Package.InstallationDirectoryPath}, but it does not seem like runbook can reach those?

Hi @anders.jensen,

Let me be the first to welcome you to the Octopus Community, it is great to see you here.

Thank you for reaching out to us with your question.

I can see what you are trying to do, but it would be great if you could tell me a little bit more as to what logs you are downloading. Are you creating these as part of your deployment? What would you like to do with your log files?

Until then, I can make a suggestion.

If you are collecting logs for each deployment could you maybe add this as a step within your deployment process instead of using a Runbook.

You could then use the System Variables to dynamically create what you need, for example:

Sending your logs to a dynamic directory as part of your deployment process.


You can also collect them dynamically from within the artifact collect step:

You can do this too with your Artifact name:


This way you can also keep your log files (artifacts) attached to each deployment, where these can be downloaded when/as needed:


Just so you are also aware, System Variables are calculated during deployment runtime, so these wont be available in a Runbook.

Depending on your use case, this may be an idea for you to consider. You will have a lot more flexibility using System Variables to collect release versions during your deployment.

I look forward to hearing from you, we can look at other options if the above isn’t fit for purpose for you.

All the best

Ok, so I did get my answer here by that System Variables are not available from Runbook after project is deployed.

Use case was that after a time of using the application, I would like to have a Runbook task that could fetch me some files from install directory, like logs, Config-files etc. Sometimes our customers perform manual changes to the configuration we deploy, and sometimes this goes bad. So instead of me logging in at the customer computer, I wanted to be able to fetch those configs and logs to see if something was wrong (bad config), or if the logs could reveal the cause of the problem.

But i guess i could make some API calls to find the path, just wondered if tis path was available from the runbook directly somehow…

Hi @anders.jensen,

You could also explore using the API to help with this to help you formulate a script. Here are some useful pointers: OctopusDeploy-Api/REST/PowerShell/Releases.

From your example of your use case, following on from my previous example to dynamically create the logs directory, I do have another idea that may be useful to you.

You could look to use a Prompted Variable within your Runbook:

For example:

Setup a prompted variable within your project:

Add the variable to your Artifact Collect step within your runbook:

You can also add this to your Artifact name if you wish:

Now when you come to run your runbook (remember to publish this) you will be prompted to add in a value:

Add in the release version you want to collect the logs from and it will pick up the logs for the release:


As I say, this is just another idea that may help. But with this you can have your runbook select any release version (that is available) from your logs. This will only work if you are dynamically creating the logs in a similar way.

Let me know if you would like any further assistance with this.


Yes, i see where you are going, but there may not be a C: drive available! But if i update the deployment process i can surely make something work! SO I’m good for now!

Thank you!

1 Like