You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shashank Gvs <sh...@gmail.com> on 2013/11/13 06:49:04 UTC

Regd: Logging issue in apache tomcat 7.0.42

Hi,

I wanted to have logging in tomcat, but currently using
juli/java.util.logging i am having a file with date in it (for example
catalina.11.12.2013.log) , i am unable to remove date as my additional
requirement is that i have to include daily rollover of the file.

Alternatively i have tried this using log4j by following the documentation.
I was able to get the log working properly if i start my tomcat using
startup,sh. But i am starting tomcat from an ant script in the following
way which is not at all forming the log. Can i be helped on this.

 <path id="tomcat.classpath">
                <fileset dir="${tomcat.dir}/lib/">
                        <patternset>
                                <include name="**/*.jar" />
                                <include name="**/*.zip" />
                        </patternset>
                </fileset>
                <pathelement location="${tomcat.dir}/bin/bootstrap.jar" />
                <pathelement location="${tomcat.dir}/bin/tomcat-juli.jar" />
        </path>
 <target name="tomcat-start" depends="tomcat-check-status"
unless="tomcat.started">
 <java classname="org.apache.catalina.startup.Bootstrap" fork="true"
spawn="true" classpathref="tomcat.classpath">
                        <jvmarg
value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
                        <jvmarg
value="-Djava.util.logging.config.file=${tomcat.dir}/conf/logging.properties"
/>
                        <jvmarg value="-Dcatalina.base=${tomcat.dir}"/>

                        <jvmarg value="-Xms${host.jvm.heap.min}" />
                        <jvmarg value="-Xmx${host.jvm.heap.max}" />
                        <jvmarg value="-XX:PermSize=${host.jvm.perm.min}"/>
                        <jvmarg
value="-XX:MaxPermSize=${host.jvm.perm.max}" />
                        <jvmarg value="-Dcatalina.home=${tomcat.dir}" />
                        <jvmarg
value="-Dcom.sun.management.jmxremote.port=1099"/>
                        <jvmarg
value="-Dcom.sun.management.jmxremote.ssl=false"/>
                        <jvmarg
value="-Dcom.sun.management.jmxremote.authenticate=false"/>

                </java>
</target>


Any help is appreciated.

Thanks & Regards,
Shashank

Re: Regd: Logging issue in apache tomcat 7.0.42

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Shashank,

On 11/13/13, 12:49 AM, Shashank Gvs wrote:
> I wanted to have logging in tomcat, but currently using 
> juli/java.util.logging i am having a file with date in it (for
> example catalina.11.12.2013.log) , i am unable to remove date as my
> additional requirement is that i have to include daily rollover of
> the file.
> 
> Alternatively i have tried this using log4j by following the
> documentation. I was able to get the log working properly if i
> start my tomcat using startup,sh. But i am starting tomcat from an
> ant script in the following way which is not at all forming the
> log. Can i be helped on this.
> 
> <path id="tomcat.classpath"> <fileset dir="${tomcat.dir}/lib/"> 
> <patternset> <include name="**/*.jar" /> <include name="**/*.zip"
> /> </patternset> </fileset> <pathelement
> location="${tomcat.dir}/bin/bootstrap.jar" /> <pathelement
> location="${tomcat.dir}/bin/tomcat-juli.jar" /> </path> <target
> name="tomcat-start" depends="tomcat-check-status" 
> unless="tomcat.started"> <java
> classname="org.apache.catalina.startup.Bootstrap" fork="true" 
> spawn="true" classpathref="tomcat.classpath">

Why not simply call catalina.sh from ant?

For example, this is my "tomcat-start" target (it's verbose, but useful):

  <target name="tomcat-start" depends="init,prepare-local-tomcat"
description="Starts the Tomcat server for your port">
    <!-- Import environment into env.* -->
    <property environment="env" />
    <!-- Set default values for env.* (""). Does not clobber! -->
    <property name="env.JAVA_OPTS" value="" />
    <property name="app.catalina-opts" value="" />
    <property name="env.CATALINA_OPTS" value="" />

    <!-- Customize the environment variables for the exec call -->
    <property name="effective.JAVA_OPTS" value="${env.JAVA_OPTS}" />
    <property name="effective.CATALINA_OPTS"
value="-Djava.library.path=&quot;${app.tomcat-home}/lib&quot;
${env.CATALINA_OPTS} ${app.catalina-opts}" />
    <condition property="security-option" value="-security">
      <equals arg1="${app.tomcat-security}" arg2="true" trim="true"
casesensitive="false" />
    </condition>
    <!-- Set default value for "security-option" (does not clobber) -->
    <property name="security-option" value="" />

<echo>===============
Starting Tomcat
===============
JAVA_HOME is ${app.java-home}
JAVA_OPTS is ${effective.JAVA_OPTS}
CATALINA_HOME is ${app.tomcat-home}
CATALINA_BASE is ${app.home.dir}
CATALINA_OPTS is ${effective.CATALINA_OPTS}
security-option is '${security-option}'
</echo>

    <exec osfamily="unix" executable="${app.tomcat-home}/bin/catalina.sh">
      <env key="JAVA_HOME" value="${app.java-home}" />
      <env key="JAVA_OPTS" value="${effective.JAVA_OPTS}" />
      <env key="CATALINA_BASE" value="${app.home.dir}" />
      <env key="CATALINA_OPTS" value="${effective.CATALINA_OPTS}" />

      <arg value="start" />
      <arg value="${security-option}" />
    </exec>

    <!-- Separate script for win32 -->
    <exec osfamily="winnt"
executable="${app.tomcat-home}/bin/catalina.bat">
      <env key="JAVA_HOME" value="${app.java-home}" />
      <env key="JAVA_OPTS" value="${effective.JAVA_OPTS}" />
      <env key="CATALINA_HOME" value="${app.tomcat-home}" />
      <env key="CATALINA_BASE" value="${app.home.dir}" />
      <env key="CATALINA_OPTS" value="${effective.CATALINA_OPTS}" />

      <arg value="start" />
      <arg value="${security-option}" />
    </exec>
  </target>

Now I don't have to worry about things like proper CLASSPATH, updating
my script when some launch parameter changes, etc.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJShCu5AAoJEBzwKT+lPKRY+osQAI2Mvcw0auW06C65/BYslr6W
aQm/QIky88XphE3IwgMrRc02FClEHA2Rz/fKQK/qqxgF3BPIUKMJaBpVFb3oJJwQ
7dHV1rDOyDfZJFPZyAnKzyxT99Rn4PolRd1ds5ZB5tfqFrHN+TePFkLxejVUAV/d
Pqf7+1cikHQGqm81EY2itBEWMMGRQwUwFrPD0C4Z8glsUElx62TB7iKTY4CGO3Ea
jxjFCe1bw/fzcGfeWxOshWXdrk8DtzwuHYUhnVfice8TRteQJyBWnCO+A3zFpTr1
C5uBEIKfGOx3A0pW2weP/Y+p9+Ur+xW4mDF/8soh66EUDdHJrH0qgndkfXtPf/6x
ZGLQdgV/wm0FJqkPcJ46aiOs7BGGDq4Ku5f+brWPHtO4sJiPjro5hshCmIZAoXyM
/47TyrwyUsd2eQ7F4m4gxsy3Bx6W6gWNG2OI6Bhs5PyI3i+r5f3O0Z9iOslQwT0O
sMLZb9w/2dpv4nIzF3T1p/IrNA7a80+m17rAfxnyFQZvV2jUajm2Aowffe+H+HAH
WUbNSX0cn7bEv9J7N/84qhsPTtKwwLRdwEF+9r5rdun0HLdWihl7CvloF7ZHjQ3G
jrsD5qsu7pUgB7xJDrnD5bv1B2eMMfFGlSnpNhsaCBdwyyFjJj6/OeDyTkdDga0r
oK6HmV6cQa0Tinq8NNMd
=+334
-----END PGP SIGNATURE-----

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


Re: Regd: Logging issue in apache tomcat 7.0.42

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/11/13 Shashank Gvs <sh...@gmail.com>:
> Hi,
>
> I wanted to have logging in tomcat, but currently using
> juli/java.util.logging i am having a file with date in it (for example
> catalina.11.12.2013.log) , i am unable to remove date as my additional
> requirement is that i have to include daily rollover of the file.

There are two ways to disable rollover (and thus the date in the filename):

a) There is property in JULI FileHandler to disable rollover.
b) You can use FileHandler class from JDK instead of JULI one.

> Alternatively i have tried this using log4j by following the documentation.
> I was able to get the log working properly if i start my tomcat using
> startup,sh. But i am starting tomcat from an ant script in the following
> way which is not at all forming the log. Can i be helped on this.
>
>  <path id="tomcat.classpath">
>                 <fileset dir="${tomcat.dir}/lib/">
>                         <patternset>
>                                 <include name="**/*.jar" />
>                                 <include name="**/*.zip" />
>                         </patternset>
>                 </fileset>

The above is wrong.

The Bootstrap class should locate & load libraries by itself (thanks
to configuration in conf/catalina.properties). The above puts the
libraries in the System classloader, which is wrong.

http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html

One more error in the above:
note that Tomcat configuration for Common classloader includes not
only "lib/*.jar" but also "lib/" directory itself.

Your configuration includes *.jar files only. Class files and
resources (such as the log4j configuration file) will not be seen by
libraries loaded with the above System classloader configuration.

The below is OK.

>                 <pathelement location="${tomcat.dir}/bin/bootstrap.jar" />
>                 <pathelement location="${tomcat.dir}/bin/tomcat-juli.jar" />
>         </path>
>  <target name="tomcat-start" depends="tomcat-check-status"
> unless="tomcat.started">
>  <java classname="org.apache.catalina.startup.Bootstrap" fork="true"
> spawn="true" classpathref="tomcat.classpath">
>                         <jvmarg
> value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
>                         <jvmarg
> value="-Djava.util.logging.config.file=${tomcat.dir}/conf/logging.properties"
> />
>                         <jvmarg value="-Dcatalina.base=${tomcat.dir}"/>
>
>                         <jvmarg value="-Xms${host.jvm.heap.min}" />
>                         <jvmarg value="-Xmx${host.jvm.heap.max}" />
>                         <jvmarg value="-XX:PermSize=${host.jvm.perm.min}"/>
>                         <jvmarg
> value="-XX:MaxPermSize=${host.jvm.perm.max}" />
>                         <jvmarg value="-Dcatalina.home=${tomcat.dir}" />
>                         <jvmarg
> value="-Dcom.sun.management.jmxremote.port=1099"/>
>                         <jvmarg
> value="-Dcom.sun.management.jmxremote.ssl=false"/>
>                         <jvmarg
> value="-Dcom.sun.management.jmxremote.authenticate=false"/>
>
>                 </java>
> </target>
>
>
> Any help is appreciated.
>
> Thanks & Regards,
> Shashank

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