title: How to log filtered values in Java Streams
body: <p>I have a requirement to <code>log/sysout</code> the filtered values in Java Streams. I am able to <code>log/sysout</code> the non-filtered value using <code>peek()</code> method. 
  However, can someone please let me know how to log filtered values?</p>
  
  <p>For example, let's say I have a list of <code>Person</code> objects like this:</p>
  
  <pre><code>List&lt;Person&gt; persons = Arrays.asList(new Person("John"), new Person("Paul"));
  </code></pre>
  
  <p>I want to filter out those persons who are not "John" as follows:</p>
  
  <pre><code>persons.stream().filter(p -&gt; !"John".equals(p.getName())).collect(Collectors.toList());
  </code></pre>
  
  <p>However, I have to log the details of that "John" person which is filtered. Can someone please help me achieve this?</p>