<p>It's in the wish list, I think. Quoting from the doc <a href="https://docs.ansible.com/ansible/latest/plugins/callback/log_plays.html" rel="nofollow noreferrer">log_plays - write playbook output to log file</a></p>

<pre><code>* This callback writes playbook output to a file per host in the /var/log/ansible/hosts directory
* TODO: make this configurable
</code></pre>

<p>IMHO required functionality is not available at the moment. Take a look at the available plugins. "<a href="https://docs.ansible.com/ansible/2.6/plugins/callback.html#managing-stdout" rel="nofollow noreferrer">You can only have one plugin</a>".</p>

<pre><code>ansible-doc -t callback -l
</code></pre>

<p>There is an option to customize a callback. <a href="https://docs.ansible.com/ansible/2.5/plugins/callback/context_demo.html" rel="nofollow noreferrer">context_demo</a> looks promising.</p>

CC BY-SA 4.0
2018-08-03T07:05:23.370Z
I got this info but there is not much documentation in link. Right now logs are going in the file but I want to stop that log for certain tasks (not hosts) and problem  that I can't use no_log: True because I want to print them on console.
user2187367
CC BY-SA 4.0
2018-08-03T06:41:50.907Z
2018-08-03T07:57:40.883Z
2018-08-03T07:57:40.883Z
Vladimir Botka
<p>I am using Ansible and created a Playbook for deployment. I defined <code>log_path</code> in <code>ansible.cfg</code> and now tasks output are going to this log file. I want to send only few task's log into this log file. How can I achieve this ?</p>

<p>One option is to use <code>no_log: True</code> attribute but this is not displaying the logs on console.</p>

<p>So my requirement is to display all task's logs in console but I want to send only few task's log to my log file.</p>

<ansible><ansible-inventory>
How to write logs for certain tasks only?
user2187367
# How to write logs for certain tasks only?

(Asked by: username_0 on 2018-08-03)

I am using Ansible and created a Playbook for deployment. I defined `log_path` in `ansible.cfg` and now tasks output are going to this log file. I want to send only few task's log into this log file. How can I achieve this ?

One option is to use `no_log: True` attribute but this is not displaying the logs on console.

So my requirement is to display all task's logs in console but I want to send only few task's log to my log file.

**Tags:** ansible, ansible-inventory


---

## 1 answers

### Answer by username_1 on 2018-08-03. Score: 1

It's in the wish list, I think. Quoting from the doc log_plays - write playbook output to log file
* This callback writes playbook output to a file per host in the /var/log/ansible/hosts directory
* TODO: make this configurable

IMHO required functionality is not available at the moment. Take a look at the available plugins. "You can only have one plugin".
ansible-doc -t callback -l

There is an option to customize a callback. context_demo looks promising.

> **Comments:**
> **username_0**: I got this info but there is not much documentation in link. Right now logs are going in the file but I want to stop that log for certain tasks (not hosts) and problem  that I can't use no_log: True because I want to print them on console.  

---

