# (1.2) added a log file for ansible and ansible-playbook

**URL:** <https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727>\
**Category:** Ansible Project\
**Created:** [April 27, 2013, 2:28pm UTC](https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727 "2013-04-27T14:28:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 27, 2013, 2:28pm UTC](https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727/1 "2013-04-27T14:28:28Z")

</div>

I’ve just pushed some upgrades that allow for optional logging of all ansible and ansible-playbook output.

To configure this, set ‘log\_path’ in your configuration file or ANSIBLE\_LOG\_PATH as an environment variable.

Dates and times of each log message are printed before the message.

It will also output the commands you run ahead of each output block.

This file will get somewhat large over time so you’ll probably want to  
configure logrotate if you are using it.

---

<div class="post-metadata">

**Author:** ![Matt\_Coddington](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Matt\_Coddington](https://forum.ansible.com/u/Matt_Coddington)\
**Post date:** [April 27, 2013, 5:06pm UTC](https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727/2 "2013-04-27T17:06:05Z")

</div>

very cool! i noticed if i’m running two playbooks simultaneously the output (obviously) gets interleaved and i can’t tell which line is coming from which execution… i put together a patch to stick the pid of the running ansible-playbook process between the date and the message; i want to test it a bit, but would you accept a pull request for something like this?

[https://github.com/mcodd/ansible/commit/3b8f69bac8feb8d3a9fc17c4a57ca0a1237014f4](https://github.com/mcodd/ansible/commit/3b8f69bac8feb8d3a9fc17c4a57ca0a1237014f4)

thanks,  
matt

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 27, 2013, 5:24pm UTC](https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727/3 "2013-04-27T17:24:04Z")

</div>

Yes, please send a pull request along for this.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 27, 2013, 5:30pm UTC](https://forum.ansible.com/t/1-2-added-a-log-file-for-ansible-and-ansible-playbook/12727/4 "2013-04-27T17:30:37Z")

</div>

BTW, be sure to handle the case where logging is configured off.
