# Logging Playbook Output - Are There Better Ways?

**URL:** <https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491>\
**Category:** Get Help\
**Created:** [July 26, 2024, 9:32am UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491 "2024-07-26T09:32:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roelvandepaar](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@roelvandepaar](https://forum.ansible.com/u/roelvandepaar)\
**Post date:** [July 26, 2024, 9:32am UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491/1 "2024-07-26T09:32:00Z")

</div>

## Logging Playbook Output - Are There Better Ways?

Hello,

so far I have tried different ways to log the output of a single Ansible Playbook execution to a file.  
In business environments you usually want to upload the logfile to some platform (e.g. `jira`) or send it to someone.  
And of course you want to automate this process, too.

#### my current approach

Right now the most feasible method for me is to do it like this:

- create a wrapper bash script around the `ansible-playbook` commands
- redirect the output of the `ansible-playbook` command to a log file
- create a second playbook that uploads the logfile to `jira`
- start that second playbook after the primary playbook in the wrapper script

#### other approaches

I have seen people `register` every `task` and write that to a log with `copy` or `lineinfile`, but that seems very cumbersome to me and makes `roles` harder to maintain.  
I know the `log_path` setting, but that appends all playbook outputs and is only helpful for looking at past playbook executions.  
And I think I have used the `log_plays` plugin which did not really do what I had in mind, it also creates a dir for every host.

So - are there better ways to do it?  
How do you log your `Ansible` runs?

Regards

---

<div class="post-metadata">

**Author:** ![McGlovin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mcglovin/32/3698_2.png) [@McGlovin](https://forum.ansible.com/u/McGlovin)\
**Post date:** [July 26, 2024, 12:56pm UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491/2 "2024-07-26T12:56:14Z")

</div>

Hi,

I would suggest looking into using an appropriate callback plugin. The `log_plays` one is probably a good starting point.

More info on callback plugins: [https://docs.ansible.com/ansible/latest/plugins/callback.html](https://docs.ansible.com/ansible/latest/plugins/callback.html)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [July 26, 2024, 5:49pm UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491/3 "2024-07-26T17:49:20Z")

</div>

I tend to use [`script`](https://www.geeksforgeeks.org/script-command-in-linux-with-examples/) to wrap around calls to `ansible-playbook`. It preserves formatting and coloring. But, I keep all the logs locally, I don’t upload them anywhere. That would require some additional bash scripting for example.

Another solution is using AWX or Ansible Semaphore or similar which by design catch Ansible output and keep the logs. `ansible-navigator` can also catch Ansible output in `json` formatted logs.

---

<div class="post-metadata">

**Author:** ![rfc2549](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rfc2549/32/197_2.png) [@rfc2549](https://forum.ansible.com/u/rfc2549)\
**Post date:** [July 30, 2024, 12:49am UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491/4 "2024-07-30T00:49:45Z")

</div>

I use ara to record ansible playbooks: [GitHub - ansible-community/ara: ARA Records Ansible and makes it easier to understand and troubleshoot.](https://github.com/ansible-community/ara)

There is a live demo if you are curious: [https://demo.recordsansible.org/](https://demo.recordsansible.org/)

---

<div class="post-metadata">

**Author:** ![Thulium-Drake](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/thulium-drake/32/833_2.png) [@Thulium-Drake](https://forum.ansible.com/u/Thulium-Drake)\
**Post date:** [August 1, 2024, 9:06am UTC](https://forum.ansible.com/t/logging-playbook-output-are-there-better-ways/7491/5 "2024-08-01T09:06:55Z")

</div>

I’m also a happy user of ARA, it’s part of the standard kit when deploying Ansible somewhere at $work

Also, to add to @rfc2549’s post, there’s also a collection to install ARA with Ansible 🙂

> **[GitHub - ansible-community/ara-collection: Collection of Ansible roles for ARA Records...](https://github.com/ansible-community/ara-collection/)**
>
> Collection of Ansible roles for ARA Records Ansible.
