<div dir="ltr">I am trying to redirect all log messages to a destination program (written in java).<br>This did not do much so I redirected all messages to a single catch-all log file AND also to a bash shell script that runs an endless loop, reads a line and spit it out to a text file.<br>

The shell script is killed by syslog-ng after the 5th message. The catch-all file, however, keeps getting all of the messages (that&#39;s how I know who is killing who).<br><br>Here is the config file for syslog-ng:<br><div style="margin-left: 40px;">
<br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">options {</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ts_format(iso);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; frac_digits(3);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">};</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">template bds_template{</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; template(&quot;&lt;pri=$PRI&gt; &lt;date=$ISODATE&gt; &lt;host=$HOST&gt; &lt;msg=$MSG&gt;\n&quot;);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">template_escape(no);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">};</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">source src{</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal();</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unix_stream(&quot;/dev/log&quot;);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unix-dgram(&quot;/dev/log&quot;);</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file(&quot;/proc/kmsg&quot; log_prefix(&quot;kernel:&quot;));</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; udp();</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tcp();</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">};</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">destination test_adapter{</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">program(&quot;bash /usr/local/bds/logger/syslogAdapterTest.sh&quot; template(bds_template));</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">};</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">log { source(src); destination(test_adapter); };</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">destination catchAll{</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">file(&quot;/var/log/syslog-ng-catch-all.log&quot;, template(bds_template));</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">};</span><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);"><br style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">
<span style="background-color: rgb(204, 204, 204); color: rgb(51, 51, 255);">log { source(src); destination(catchAll); };</span><br></div><br>Here is the bash script:<br><br><div style="margin-left: 40px; background-color: rgb(204, 204, 204); color: rgb(0, 0, 153);">
#!/bin/bash<br><br>file=&quot;/root/syslogAdapterTest&quot;<br>counter=1<br>limit=3<br><br><br>while true<br></div><div style="margin-left: 80px; background-color: rgb(204, 204, 204); color: rgb(0, 0, 153);">do<br></div><div style="margin-left: 80px; background-color: rgb(204, 204, 204); color: rgb(0, 0, 153);">
<div style="margin-left: 40px;">read line<br>echo &quot;$line&quot; &gt; $file.$counter<br>((counter++))<br></div></div><div style="margin-left: 80px; background-color: rgb(204, 204, 204); color: rgb(0, 0, 153);">done<br>
</div><br>and finally the content of the catch-all file, in blue are the log messages that the shell script still captures and spits to text files, in red are the messages are the messages the shell does not get:<br><br><div style="margin-left: 40px; background-color: rgb(204, 204, 204); color: rgb(0, 0, 153);">
&lt;pri=45&gt; &lt;date=2008-08-19T15:13:56.191-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: Server license found, starting in server mode; customer=&#39;University of Illinois&#39;, serial=&#39;49544f30-573e-11dd-9892-0007e9195011&#39;, limit=&#39;25&#39;&gt;<br>
&lt;pri=46&gt; &lt;date=2008-08-19T15:13:56.191-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: Starting destination program; cmdline=&#39;bash /usr/local/bds/logger/syslogAdapterTest.sh&#39;&gt;<br>&lt;pri=45&gt; &lt;date=2008-08-19T15:13:56.193-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: syslog-ng starting up; version=&#39;2.1.11a&#39;&gt;<br>
&lt;pri=46&gt; &lt;date=2008-08-19T15:13:56.193-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: Initializing destination file writer; template=&#39;/var/log/syslog-ng-catch-all.log&#39;, filename=&#39;/var/log/syslog-ng-catch-all.log&#39;&gt;<br>
&lt;pri=45&gt; &lt;date=2008-08-19T15:13:56.193-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: License validity expires in one week, logging service will terminate at that point; error=&#39;License outside the validity period (option=syslog-ng, not-before=2008/07/21, not-after=2008/08/21)&#39;&gt;<br>
<b style="color: rgb(204, 0, 0);">&lt;pri=43&gt; &lt;date=2008-08-19T15:13:56.198-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: I/O error occurred while writing; fd=&#39;11&#39;, error=&#39;Broken pipe (32)&#39;&gt;<br>
&lt;pri=46&gt; &lt;date=2008-08-19T15:13:56.198-05:00&gt; &lt;host=oracle-test&gt; &lt;msg=syslog-ng[27971]: Sending child a TERM signal; child_pid=&#39;27972&#39;&gt;</b><br></div><br>Any idea?<br></div>