tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy <tom1...@andy-t.org>
Subject RE: Runaway catalina.out logging
Date Wed, 09 May 2007 16:26:01 GMT
You are right.  To generalize this: It is all a matter of shell 
precedences.

Pipe (|) has a higher precedence than angle redirect (>) which is why 
redirect is needed on both sides.  However, grouping two commands with 
parentheses overrides this behavior, again because parentheses have even 
higher precedence.  I guess I have worded it very awkwardly, so here is a 
set of examples:

# Errors from two commands, both sent to stderr
bash-2.05b$ ls /aaa | sort -q
sort: invalid option -- q
Try `sort --help' for more information.
ls: /aaa: No such file or directory

# Error from the first command suppressed, error from the second shows
bash-2.05b$ ls /aaa >/dev/null 2>&1 | sort -q
sort: invalid option -- q
Try `sort --help' for more information.

# Error from the first command shows, error from the second suppressed
bash-2.05b$ ls /aaa | sort -q >/dev/null 2>&1
ls: /aaa: No such file or directory

# Errors from both commands suppressed independently
bash-2.05b$ ls /aaa >/dev/null 2>&1 | sort -q >/dev/null 2>&1

# Errors from both commands suppressed together
bash-2.05b$ (ls /aaa | sort -q) >/dev/null 2>&1

Regards,

Andy

On Wed, 9 May 2007, Fargusson.Alan wrote:

> At the risk of over explaining, this is one of those slightly tricky areas of shell syntax.
>
> The general form of the command below would be something like:
> 	ls -l | pr > Out
>
> Now there are two commands that might generate errors to the terminal.  So you do this:
> 	ls -l | pr > Out 2>&1
>
> Now you might still see errors output to the terminal.  The above redirects the output
of the pr command, but not the ls command.  So you have to do this:
> 	ls -l 2>&1 | pr > Out 2>&1
>
> The first 2>&1 redirects the stderr of the ls command into the pipe.  The second
2>&1 redirects the output of pr to the file named Out.
>
> The syntax for redirecting stderr to a pipe is a little odd, but in order to get this
right it needs to be something like this.
>
> -----Original Message-----
> From: Andy [mailto:tom1cat@andy-t.org]
> Sent: Tuesday, May 08, 2007 7:11 PM
> To: Tomcat Users List
> Subject: Re: Runaway catalina.out logging
>
>
> Filip,
>
> This works, thanks, although I am still not sure why the original failed.
> Too many players in a single command...
>
> Regards,
>
> Andy
>
> On Wed, 9 May 2007, Filip Hanik - Dev Lists wrote:
>
>> change
>>      | /u00/tomcat/bin/logger "$CATALINA_BASE"/logs/catalina 2>&1 &
>> to
>>      2>&1 | /u00/tomcat/bin/logger "$CATALINA_BASE"/logs/catalina 2>&1
&
>>
>> ie, redirect stderr into stdout before passing it into the logger
>>
>> Filip
>>
>> Andy wrote:
>>> This is a correction of the Subject: which I failed to set properly in my
>>> original message.  Sorry...
>>>
>>> Hi there,
>>>
>>> We have recently switched to tomcat-5.5, on SuSE 9.3, and I ran into a
>>> strange problem that was not there before.
>>>
>>> I am using a custom script from catalina.out rotation.  It works much the
>>> same way as cronolog, except it is much simpler and does more (if anyone
>>> wants to see/use it, let me know ;)  ).  The script is invoked using the
>>> same approach, from catalina.sh:
>>>
>>> I replace
>>>
>>>       >> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
>>>
>>> with
>>>
>>>        | /u00/tomcat/bin/logger "$CATALINA_BASE"/logs/catalina 2>&1 &
>>>
>>> This used to work perfectly.  But with ver.5.5, some startup and shutdown
>>> messages "escape" to the terminal.  The rest goes to the script as before.
>>> It seems that for those messages, tomcat explicitly uses a file descriptor
>>> that corresponds to the terminal, or some such thing.
>>>
>>> Anyone has an idea why this is happening, and how I can capture the
>>> runaways?  Any help would be greatly appreciated.
>>>
>>> Regards,
>>>
>>> Andy Tsouladze
>>>
>>> Escaping startup messages:
>>>
>>> May 8, 2007 5:45:41 PM org.apache.catalina.core.AprLifecycleListener
>>> lifecycleEvent
>>> INFO: The Apache Tomcat Native library which allows optimal performance in
>>> production environments was not found on the java.library.path:
>>> /usr/java/jre1.5.0_11/lib/amd64/server:/usr/java/jre1.5.0_11/lib/amd64:/usr/
>>> java/jre1.5.0_11/../lib/amd64
>>> May 8, 2007 5:45:41 PM org.apache.coyote.http11.Http11BaseProtocol init
>>> INFO: Initializing Coyote HTTP/1.1 on http-8080
>>> May 8, 2007 5:45:42 PM org.apache.coyote.http11.Http11BaseProtocol init
>>> INFO: Initializing Coyote HTTP/1.1 on http-8443
>>>> May 8, 2007 5:45:42 PM org.apache.catalina.startup.Catalina load
>>> INFO: Initialization processed in 1776 ms
>>> May 8, 2007 5:45:42 PM org.apache.catalina.core.StandardService start
>>> INFO: Starting service Catalina
>>> May 8, 2007 5:45:42 PM org.apache.catalina.core.StandardEngine start
>>> INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
>>> May 8, 2007 5:45:42 PM org.apache.catalina.core.StandardHost start
>>> INFO: XML validation disabled
>>> May 8, 2007 5:45:43 PM org.apache.catalina.core.StandardContext start
>>> SEVERE: Error listenerStart
>>> May 8, 2007 5:45:43 PM org.apache.catalina.core.StandardContext start
>>> SEVERE: Context [/axis] startup failed due to previous errors
>>> May 8, 2007 5:45:44 PM org.apache.coyote.http11.Http11BaseProtocol start
>>> INFO: Starting Coyote HTTP/1.1 on http-8080
>>> May 8, 2007 5:45:44 PM org.apache.coyote.http11.Http11BaseProtocol start
>>> INFO: Starting Coyote HTTP/1.1 on http-8443
>>> May 8, 2007 5:45:44 PM org.apache.jk.common.ChannelSocket init
>>> INFO: JK: ajp13 listening on /0.0.0.0:8009
>>> May 8, 2007 5:45:44 PM org.apache.jk.server.JkMain start
>>> INFO: Jk running ID=0 time=0/82  config=null
>>> May 8, 2007 5:45:44 PM org.apache.catalina.storeconfig.StoreLoader load
>>> INFO: Find registry server-registry.xml at classpath resource
>>> May 8, 2007 5:45:44 PM org.apache.catalina.startup.Catalina start
>>> INFO: Server startup in 2181 ms
>>>
>>>
>>> Escaping shutdown messages:
>>>
>>>
>>> May 8, 2007 5:47:25 PM org.apache.coyote.http11.Http11BaseProtocol pause
>>> INFO: Pausing Coyote HTTP/1.1 on http-8080
>>> May 8, 2007 5:47:25 PM org.apache.coyote.http11.Http11BaseProtocol pause
>>> INFO: Pausing Coyote HTTP/1.1 on http-8443
>>> csapp02:/u00/jakarta/bin # May 8, 2007 5:47:26 PM
>>> org.apache.catalina.core.StandardService stop
>>> INFO: Stopping service Catalina
>>> May 8, 2007 5:47:26 PM org.apache.coyote.http11.Http11BaseProtocol destroy
>>> INFO: Stopping Coyote HTTP/1.1 on http-8080
>>> May 8, 2007 5:47:26 PM org.apache.coyote.http11.Http11BaseProtocol destroy
>>> INFO: Stopping Coyote HTTP/1.1 on http-8443
>>> May 8, 2007 5:47:26 PM org.apache.catalina.core.AprLifecycleListener
>>> lifecycleEvent
>>> INFO: Failed shutdown of Apache Portable Runtime
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message