You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Edson Richter <ed...@hotmail.com> on 2013/01/30 23:01:54 UTC

Cannot apply simpleformtatter pattern to catalina.sh

I'm trying to put the following in catalina.sh:

JAVA_OPTS=-Djava.awt.headless=true 
-Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td 
%1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n

also tried:

JAVA_OPTS="-Djava.awt.headless=true 
-Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td 
%1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n"


Both causes errors (linux platform) like

"/etc/init.d/catalina: line 64: 
-Djava.util.logging.SimpleFormatter.format=[%1-%1-%1: command not found"

or

"Error: Could not find or load main class %1:%1:%1.%1]"


I'll appreciate your help.

Edson Richter


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


Re: Cannot apply simpleformtatter pattern to catalina.sh

Posted by Edson Richter <ed...@hotmail.com>.
Thanks, already solved!
You are right, the double quotes are mandatory. But in this case, to 
avoid variable expansion (in bash), need also to escape the dolar signs.
And finally, the format need to be surrounded by single quotes.

What did I accomplish? The end of double log lines in log file :-)

My catalina.out now looks like:

[2013-01-30 19:22:35.593] Informações: The APR based Apache Tomcat 
Native library which allows optimal performance in production 
environments was not found on the java.library.path: 
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
[2013-01-30 19:22:36.233] Informações: Initializing ProtocolHandler 
["http-bio-80"]
[2013-01-30 19:22:36.253] Informações: Initialization processed in 1396 ms
[2013-01-30 19:22:36.322] Informações: Starting service Catalina
[2013-01-30 19:22:36.324] Informações: Starting Servlet Engine: Apache 
Tomcat/7.0.35
[2013-01-30 19:22:36.336] Informações: Deploying web application archive 
/opt/apache-tomcat-7.0.35/webapps/Studi.war

Which is much more readable than the old format:

Jan 30, 2013 4:40:13 PM org.apache.catalina.core.AprLifecycleListener init
Informações: The APR based Apache Tomcat Native library which allows 
optimal performance in production environme    nts was not found on the 
java.library.path: 
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Jan 30, 2013 4:40:15 PM org.apache.coyote.AbstractProtocol init
Informações: Initializing ProtocolHandler ["http-bio-8080"]
Jan 30, 2013 4:40:15 PM org.apache.coyote.AbstractProtocol init
Informações: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 30, 2013 4:40:15 PM org.apache.catalina.startup.Catalina load
Informações: Initialization processed in 3933 ms


and so on...



Em 30/01/2013 20:26, Mark Eggers escreveu:
> On 1/30/2013 2:01 PM, Edson Richter wrote:
>> I'm trying to put the following in catalina.sh:
>>
>> JAVA_OPTS=-Djava.awt.headless=true
>> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td
>> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n
>>
>> also tried:
>>
>> JAVA_OPTS="-Djava.awt.headless=true
>> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td
>> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n"
>>
>>
>> Both causes errors (linux platform) like
>>
>> "/etc/init.d/catalina: line 64:
>> -Djava.util.logging.SimpleFormatter.format=[%1-%1-%1: command not
>> found"
>>
>> or
>>
>> "Error: Could not find or load main class %1:%1:%1.%1]"
>>
>>
>> I'll appreciate your help.
>>
>> Edson Richter
>
> What version of Tomcat? Please give the full version (x.y.z).
>
> What are you trying to accomplish?
>
> Did you put a copy of catalina.sh as catalina in /etc/init.d or is 
> this a third party distribution? I've not seen one that places 
> catalina.sh as catalina in /etc/init.d, but I've not worked a lot with 
> repackaged Tomcats.
>
> Probably the best way to handle this is find out where your 
> distribution thinks $CATALINA_HOME is, and then edit a setenv.sh file 
> in $CATALINA_HOME/bin to include environment variables.
>
> This file is not included by default - you'll have to create your own.
>
> Also, when you enter multiple values for an environment variable, 
> you'll have to surround the entire thing with quotes. For example:
>
> JAVA_OPTS="-Dfoo=something -Dbar=else"
>
> This all assumes that your distribution (if you're using one) hasn't 
> mangled catalina.sh and removed references to setenv.sh.
>
> . . . . more guesses with more information
> /mde/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


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


Re: Cannot apply simpleformtatter pattern to catalina.sh

Posted by Mark Eggers <it...@yahoo.com>.
On 1/30/2013 2:01 PM, Edson Richter wrote:
> I'm trying to put the following in catalina.sh:
>
> JAVA_OPTS=-Djava.awt.headless=true
> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td
> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n
>
> also tried:
>
> JAVA_OPTS="-Djava.awt.headless=true
> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td
> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n"
>
>
> Both causes errors (linux platform) like
>
> "/etc/init.d/catalina: line 64:
> -Djava.util.logging.SimpleFormatter.format=[%1-%1-%1: command not
> found"
>
> or
>
> "Error: Could not find or load main class %1:%1:%1.%1]"
>
>
> I'll appreciate your help.
>
> Edson Richter

What version of Tomcat? Please give the full version (x.y.z).

What are you trying to accomplish?

Did you put a copy of catalina.sh as catalina in /etc/init.d or is this 
a third party distribution? I've not seen one that places catalina.sh as 
catalina in /etc/init.d, but I've not worked a lot with repackaged Tomcats.

Probably the best way to handle this is find out where your distribution 
thinks $CATALINA_HOME is, and then edit a setenv.sh file in 
$CATALINA_HOME/bin to include environment variables.

This file is not included by default - you'll have to create your own.

Also, when you enter multiple values for an environment variable, you'll 
have to surround the entire thing with quotes. For example:

JAVA_OPTS="-Dfoo=something -Dbar=else"

This all assumes that your distribution (if you're using one) hasn't 
mangled catalina.sh and removed references to setenv.sh.

. . . . more guesses with more information
/mde/

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


Re: Cannot apply simpleformtatter pattern to catalina.sh

Posted by Edson Richter <ed...@hotmail.com>.
Ops!

Found it:

JAVA_OPTS="-Djava.awt.headless=true 
-Djava.util.logging.SimpleFormatter.format='[%1\$tY-%1\$tm-%1\$td 
%1\$tH:%1\$tM:%1\$tS.%1\$tL] %4\$s: %5\$s %6\$s %n' "

a) In bash, using double quotes make necessary to escape the dolar sign
b) for SimpleFormatter.format works, the formatting experssion needs to 
be inside single quotes.

Regards,

Edson

Em 30/01/2013 20:01, Edson Richter escreveu:
> I'm trying to put the following in catalina.sh:
>
> JAVA_OPTS=-Djava.awt.headless=true 
> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td 
> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n
>
> also tried:
>
> JAVA_OPTS="-Djava.awt.headless=true 
> -Djava.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td 
> %1$tH:%1$tM:%1$tS.%1$tL] %4$s: %5$s %6$s %n"
>
>
> Both causes errors (linux platform) like
>
> "/etc/init.d/catalina: line 64: 
> -Djava.util.logging.SimpleFormatter.format=[%1-%1-%1: command not found"
>
> or
>
> "Error: Could not find or load main class %1:%1:%1.%1]"
>
>
> I'll appreciate your help.
>
> Edson Richter
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


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


RE: Cannot apply simpleformtatter pattern to catalina.sh

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Edson Richter [mailto:edsonrichter@hotmail.com] 
> Subject: Cannot apply simpleformtatter pattern to catalina.sh

> I'm trying to put the following in catalina.sh:

Don't do that.  Create a setenv.sh script and put the lines there.

Looks like you found the lack of escaping.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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