# log\_path and callback plugin

**URL:** <https://forum.ansible.com/t/log-path-and-callback-plugin/23964>\
**Category:** Ansible Project\
**Created:** [March 14, 2017, 10:37am UTC](https://forum.ansible.com/t/log-path-and-callback-plugin/23964 "2017-03-14T10:37:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [March 14, 2017, 10:37am UTC](https://forum.ansible.com/t/log-path-and-callback-plugin/23964/1 "2017-03-14T10:37:37Z")

</div>

Hello,

I would like to log in a file the output of the display when running a playbook, this is set with the log\_path variable in logs/ansible.log  
But I would like the output to be dispatch in a logfile whose name would be the playbook\_name.hostname.nupro  
I have a plugin that log into such a file but I cannot log the display log,

Example: the display of the ansible-playbook command, looged in the logfile set by the log\_path variable, when running the test\_failed.yml playbook:

2017-03-14 11:30:53,570 p=3101 u=fvaltat | Using /home/fvaltat/PLUGINS/ansible.cfg as config file  
2017-03-14 11:30:53,615 p=3101 u=fvaltat | Loaded callback default of type stdout, v2.0  
2017-03-14 11:30:53,651 p=3101 u=fvaltat | Loaded callback perserver\_log of type old, v2.0  
2017-03-14 11:30:53,654 p=3101 u=fvaltat | PLAYBOOK: test\_failed.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2017-03-14 11:30:53,654 p=3101 u=fvaltat | 2 plays in test\_failed.yml  
2017-03-14 11:30:53,663 p=3101 u=fvaltat | PLAY [RD:!host2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2017-03-14 11:30:53,706 p=3101 u=fvaltat | TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2017-03-14 11:30:54,342 p=3101 u=fvaltat | ok: [localhost]  
2017-03-14 11:30:54,352 p=3101 u=fvaltat | TASK [set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2017-03-14 11:30:54,352 p=3101 u=fvaltat | task path: /home/fvaltat/PLUGINS/test\_failed.yml:3  
2017-03-14 11:30:54,383 p=3101 u=fvaltat | ok: [localhost] =\> {“ansible\_facts”: {“var”: false}, “changed”: false, “invocation”: {“module\_args”: {“var”: false}, “module\_name”: “set\_fact”}}  
2017-03-14 11:30:54,391 p=3101 u=fvaltat | TASK [fail] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

2017-03-14 11:30:54,392 p=3101 u=fvaltat | task path: /home/fvaltat/PLUGINS/test\_failed.yml:5  
2017-03-14 11:30:54,463 p=3101 u=fvaltat | fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_args”: {“msg”: “failed”}, “module\_name”: “fail”}, “msg”: “failed”}  
2017-03-14 11:30:54,469 p=3101 u=fvaltat | NO MORE HOSTS LEFT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2017-03-14 11:30:54,470 p=3101 u=fvaltat | to retry, use: --limit @/home/fvaltat/PLUGINS/test\_failed.retry

The contents of the logfile test\_failed.yml\_localhost\_3101 created by the callback plugin:

2017-03-14.11:30:54: msg : failed

Is there an easy way to proceed to rename the ansible.log file during the run of the ansible-playbook command and not in a script ?  
I tried to use the log\_plays plugin without any success

Regards

---

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [March 14, 2017, 11:50am UTC](https://forum.ansible.com/t/log-path-and-callback-plugin/23964/2 "2017-03-14T11:50:19Z")

</div>

Is it possible to set the logfilename in the default.py file ? or should this be done in another callback plugin ?
