using Sed with grep for the log file

I was trying to make php error logs visibly good whenever I do error_log($ex->getTraceAsString()) but it printed n so I figured out the possibilities, it turned out that I should do that from terminal itself

so I do

 tail -f /var/log/apache2/error.log | sed 's/\n/n/g'

But Previously for my logs I used to do

tail -f /var/log/apache2/error.log | grep production

for logs that contains the keyword production

But I want both of them what should I do?.So that my both criteria worked

I tried

tail -f /var/log/apache2/error.log | grep production | sed 's/\n/n/g'
tail -f /var/log/apache2/error.log | sed 's/\n/n/g' | grep production 
(tail -f /var/log/apache2/error.log | grep production) | sed 's/\n/n/g'
(tail -f /var/log/apache2/error.log | sed 's/\n/n/g') | grep production 

But none of these worked. What should I do?

Answer

Add the search string to the sed statement with /…./ and so:

tail -f /var/log/apache2/error.log | sed -n '/production/s/\n/n/gp'