Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-03T07:05:23.370Z
Answers: 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.
Answers: user2187367
Answers: CC BY-SA 4.0
Answers: 2018-08-03T06:41:50.907Z
Answers: 2018-08-03T07:57:40.883Z
Answers: 2018-08-03T07:57:40.883Z
Answers: Vladimir Botka
Body: <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>
  
Tags: <ansible><ansible-inventory>
Title: How to write logs for certain tasks only?
UserDisplayName: user2187367
ThreadText: # 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](https://docs.ansible.com/ansible/latest/plugins/callback/log_plays.html)
  
  ```
  * 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](https://docs.ansible.com/ansible/2.6/plugins/callback.html#managing-stdout)".
  
  ```
  ansible-doc -t callback -l
  
  ```
  
  There is an option to customize a callback. [context\_demo](https://docs.ansible.com/ansible/2.5/plugins/callback/context_demo.html) 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.  
  
  ---
  
  