# How to store ansible running log to separate log file without touch ANSIBLE\_LOG\_PATH or ansible.cfg

**URL:** <https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785>\
**Category:** Ansible Developer\
**Created:** [February 27, 2019, 7:23am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785 "2019-02-27T07:23:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qin\_Peter](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@Qin\_Peter](https://forum.ansible.com/u/Qin_Peter)\
**Post date:** [February 27, 2019, 7:23am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785/1 "2019-02-27T07:23:21Z")

</div>

Hi All,  
This is Peter and I am newer to Ansible.

I am trying to store the ansible running log to a file. And every playbook will have separate ansible running log file.  
I know I can use ‘export ANSIBLE\_LOG\_PATH=~/share/logging/peter.log’ this variable to do this. But is there any other way?

I prefer a command line parameter or a module. I would like to do some development work but I need some directive guidance.

I cannot use plugin because I cannot affect other ansible users, also I have no right to change the ansible.cfg file. Too much limitataion from the boss, right?

Thanks for any help.

Best Regards,  
Peter Qin

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [March 1, 2019, 6:37am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785/2 "2019-03-01T06:37:00Z")

</div>

How about running the ansible playbook Andy pipe to tee command such as this

Ansible-playbook -I inventory dummy.yml | tee playbook.log

---

<div class="post-metadata">

**Author:** ![Qin\_Peter](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@Qin\_Peter](https://forum.ansible.com/u/Qin_Peter)\
**Post date:** [March 1, 2019, 6:47am UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785/3 "2019-03-01T06:47:07Z")

</div>

Thanks for the help.  
The customer will execute the command so I should work in the playbook.  
And what I need to store is running log like below, not the stand output. Do you have any other suggestions? Thanks.

1 2019-02-28 21:27:57,795 p=6115 u=peterqi | PLAY [test1 output] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
2 2019-02-28 21:27:57,806 p=6115 u=peterqi | TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\>  
3 2019-02-28 21:27:58,259 paramiko.transport starting thread (client mode): 0xfa683450L  
4 2019-02-28 21:27:58,259 paramiko.transport Local version/idstring: SSH-2.0-paramiko\_2.4.1  
5 2019-02-28 21:27:58,267 paramiko.transport Remote version/idstring: SSH-2.0-OpenSSH\_6.6.1  
6 2019-02-28 21:27:58,267 paramiko.transport Connected (version 2.0, client OpenSSH\_6.6.1)  
7 2019-02-28 21:27:58,270 paramiko.transport kex algos:[u’curve25519-sha256@libssh.org’, u’ecdh-sha2-nistp256’, u’ecdh-sha2-nistp384’, u’ecdh-sha2-nistp521’, u’diffie-hellma\>  
8 2019-02-28 21:27:58,270 paramiko.transport Kex agreed: ecdh-sha2-nistp256  
9 2019-02-28 21:27:58,270 paramiko.transport HostKey agreed: ssh-ed25519  
10 2019-02-28 21:27:58,270 paramiko.transport Cipher agreed: aes128-ctr  
11 2019-02-28 21:27:58,270 paramiko.transport MAC agreed: hmac-sha2-256  
12 2019-02-28 21:27:58,270 paramiko.transport Compression agreed: none

在 2019年3月1日星期五 UTC+8下午2:37:00，Tony Chia写道：

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [March 1, 2019, 2:46pm UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785/4 "2019-03-01T14:46:14Z")

</div>

If you are trying to get debug or connection info , try adding -vvvvv to tha ansible-playbook command.

---

<div class="post-metadata">

**Author:** ![Mike\_Klebolt](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Klebolt](https://forum.ansible.com/u/Mike_Klebolt)\
**Post date:** [March 5, 2019, 9:47pm UTC](https://forum.ansible.com/t/how-to-store-ansible-running-log-to-separate-log-file-without-touch-ansible-log-path-or-ansible-cfg/29785/5 "2019-03-05T21:47:08Z")

</div>

Try creating an alias.

`alias ansible-playbook='ANSIBLE_LOG_PATH="${HOME}/logs/ansible-$(date +%H%M%S).log" ansible-playbook'`
