{"id":840,"date":"2010-01-08T11:28:52","date_gmt":"2010-01-08T11:28:52","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=840"},"modified":"2011-11-17T13:54:02","modified_gmt":"2011-11-17T13:54:02","slug":"using-logging-with-the-eclipse-tomcat-server-adapter","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=840","title":{"rendered":"Using Logging with the Eclipse Tomcat Server Adapter"},"content":{"rendered":"<p>This post continues from <a title=\"http:\/\/salientsoft.co.uk\/?p=546\" href=\"http:\/\/salientsoft.co.uk\/?p=546\"><strong>my previous post<\/strong><\/a> on using the Tomcat Server Adapter, and details how to enable and configure logging. Configuring this is not obvious,\u00a0and there are a number of issues :-<\/p>\n<ol>\n<li>Eclipse does not fully enable logging\u00a0for the Tomcat Adapter by default, so you will likely find application log calls not going anywhere, and any <strong>logging.properties<\/strong> file you set up won&#8217;t have any effect.<\/li>\n<li>The Tomcat Adapter ignores any <strong>logging.properties<\/strong> file placed in <strong>WEB-INF\\lib <\/strong>completely. You can only use one in the &lt;Cataline \u00a0Base&gt;<strong>\\conf<\/strong> directory. More is said on the actual location of this directory later.<\/li>\n<li>The configuration instructions are somewhat buried in the Eclipse WTP FAQ.<\/li>\n<\/ol>\n<p>To enable logging for the Server Adapter, <a title=\"http:\/\/wiki.eclipse.org\/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F\" href=\"http:\/\/wiki.eclipse.org\/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F\"><strong>see here in the Eclipse WTP FAQ<\/strong><\/a>, details copied as follows. Note that the same procedure works on Eclipse Galileo 3.5.1 and Tomcat 6.0.24\u00a0:-<\/p>\n<blockquote><p><strong>How do I enable the JULI logging in a Tomcat 5.5 Server instance?<\/strong><\/p>\n<p>Tomcat 5.5 comes with an enhanced implementation of java.util.logging, called JULI, which is configured by default in a standard Tomcat 5.5 installation. This JULI logging configuration is not picked up automatically when creating a new Tomcat 5.5 server in WTP. Some manual steps are necessary to add this configuration to your WTP Tomcat 5.5 server.<\/p>\n<ol>\n<li>Open the server editor for the Tomcat server and note the folder specified by the Configuration path field.<\/li>\n<li>Import the logging.properties file from the conf directory of your Tomcat 5.5 installation into this folder in your workspace.<\/li>\n<li>In the server editor, click on the Open launch configuration link and in the launch configuration Properties dialog, switch to the Arguments tab.<\/li>\n<li>In the VM Arguments field, add the following two system properties substituting the catalina.base path where noted:<br \/>\n-Djava.util.logging.config.file=&#8221;&lt;put catalina.base path here&gt;\/conf\/logging.properties&#8221;<br \/>\n-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager<\/li>\n<\/ol>\n<p>The imported logging.properties file can be used to control the JULI logging configuration for the Tomcat server.<\/p><\/blockquote>\n<p>Note that in my case I had set up the adapter to use the Workspace Metatdata so that the installed Tomcat server could also be used independently. Therefore, the <strong>cataline base path<\/strong> used was the configuration directory used by eclipse, listed as the configuration path on the Server Overview screen (double click the server to see this screen). My settings for the VM arguments were therefore as follows :-<\/p>\n<pre>-Djava.util.logging.config.file=\r\n   \"E:\\Java\\Dev\\Workspaces\\Sentry1\\Servers\\\r\n     Tomcat v6.0 Server at localhost-config\\logging.properties\"\r\n-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager<\/pre>\n<p>This allowed me to expand the Server node for the server\u00a0in the package explorer, and open the logging.properties file directly from there.<\/p>\n<p>The following example <strong>logging.properties<\/strong> file illustrates the configuration of the logging. Tomcat uses <strong>JULI<\/strong>, an extended version of <strong>java.util.logging<\/strong> which allows extra features. It has\u00a0the abilility to support per-application logging\u00a0 &#8211; note that as above this is not supported in the Eclipse Server Adapter version, although for development time debugging this is not an issue, as you can\u00a0have separate Tomcat configuration per Eclipse workspace if you store the Tomcat configuration in the Workspace metadata as above. <strong>JULI <\/strong>also allows multiple handlers to be loaded from the same class instance. See <strong><a title=\"http:\/\/tomcat.apache.org\/tomcat-5.5-doc\/logging.html\" href=\"http:\/\/tomcat.apache.org\/tomcat-5.5-doc\/logging.html\">here<\/a> <\/strong>for the\u00a0official Tomcat documentation\u00a0for configuring Tomcat logging.<\/p>\n<p>The following example <strong>logging.properties<\/strong> file illustrates some configuration points :-<\/p>\n<p>A custom console handler has been added to the <strong>handlers<\/strong> property at the top of the file, to allow <strong>uk.co.salientsoft<\/strong> to have finer grained logging than the default console logger. The default handler has a level of <strong>FINE, <\/strong>which would prevent other lower level loggers from using <strong>FINER <\/strong>or <strong>FINEST<\/strong>. Adding the additional handler allows all the existing logging to remain as is, but gives full flexibility to <strong>uk.co.salientsoft<\/strong> logging :-<\/p>\n<pre>handlers = 1catalina.org.apache.juli.FileHandler, \\\r\n           2localhost.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0       3manager.org.apache.juli.FileHandler, \\\r\n           4host-manager.org.apache.juli.FileHandler, \\\r\n      \u00a0\u00a0\u00a0\u00a0 java.util.logging.ConsoleHandler, \\\r\n           5salientsoft.java.util.logging.ConsoleHandler<\/pre>\n<p>The new console handler is used to configure logging at <strong>FINEST <\/strong>level at the bottom of the file :-<\/p>\n<pre>5salientsoft.java.util.logging.ConsoleHandler.level = FINEST\r\n5salientsoft.java.util.logging.ConsoleHandler.formatter = \\\r\n   java.util.logging.SimpleFormatter\r\nuk.co.salientsoft.handlers = \\\r\n   1catalina.org.apache.juli.FileHandler, \\\r\n   5salientsoft.java.util.logging.ConsoleHandler\r\nuk.co.salientsoft.level = FINEST<\/pre>\n<p>The following is a complete listing of the sample <strong>logging.properties<\/strong> file :-<\/p>\n<pre># Licensed to the Apache Software Foundation (ASF) under one or more\r\n# contributor license agreements.\u00a0 See the NOTICE file distributed with\r\n# this work for additional information regarding copyright ownership.\r\n# The ASF licenses this file to You under the Apache License, Version 2.0\r\n# (the \"License\"); you may not use this file except in compliance with\r\n# the License.\u00a0 You may obtain a copy of the License at\r\n#\r\n#\u00a0\u00a0\u00a0\u00a0 http:\/\/www.apache.org\/licenses\/LICENSE-2.0\r\n#\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS,\r\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n# See the License for the specific language governing permissions and\r\n# limitations under the License.\r\n\r\nhandlers = 1catalina.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2localhost.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3manager.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4host-manager.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.util.logging.ConsoleHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5salientsoft.java.util.logging.ConsoleHandler\r\n\r\n.handlers = 1catalina.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 java.util.logging.ConsoleHandler\r\n\r\n############################################################\r\n# Handler specific properties.\r\n# Describes specific configuration info for Handlers.\r\n############################################################\r\n\r\n1catalina.org.apache.juli.FileHandler.level = FINE\r\n1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}\/logs\r\n1catalina.org.apache.juli.FileHandler.prefix = catalina.\r\n\r\n2localhost.org.apache.juli.FileHandler.level = FINE\r\n2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}\/logs\r\n2localhost.org.apache.juli.FileHandler.prefix = localhost.\r\n\r\n3manager.org.apache.juli.FileHandler.level = FINE\r\n3manager.org.apache.juli.FileHandler.directory = ${catalina.base}\/logs\r\n3manager.org.apache.juli.FileHandler.prefix = manager.\r\n\r\n4host-manager.org.apache.juli.FileHandler.level = FINE\r\n4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}\/logs\r\n4host-manager.org.apache.juli.FileHandler.prefix = host-manager.\r\n\r\njava.util.logging.ConsoleHandler.level = FINE\r\njava.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter\r\n\r\n############################################################\r\n# Facility specific properties.\r\n# Provides extra control for each logger.\r\n############################################################\r\n\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = \\\r\n\u00a0\u00a0 2localhost.org.apache.juli.FileHandler\r\n\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\/manager].level = INFO\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\/manager].handlers = \\\r\n\u00a0\u00a0 3manager.org.apache.juli.FileHandler\r\n\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\/host-manager].level = \\\r\n\u00a0\u00a0 INFO\r\norg.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\/host-manager].handlers = \\\r\n\u00a0\u00a0 4host-manager.org.apache.juli.FileHandler\r\n\r\n5salientsoft.java.util.logging.ConsoleHandler.level = FINEST\r\n5salientsoft.java.util.logging.ConsoleHandler.formatter = \\\r\n\u00a0\u00a0 java.util.logging.SimpleFormatter\r\nuk.co.salientsoft.handlers = 1catalina.org.apache.juli.FileHandler, \\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5salientsoft.java.util.logging.ConsoleHandler\r\nuk.co.salientsoft.level = FINEST<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post continues from my previous post on using the Tomcat Server Adapter, and details how to enable and configure logging. Configuring this is not obvious,\u00a0and there are a number of issues :- Eclipse does not fully enable logging\u00a0for the Tomcat Adapter by default, so you will likely find application log calls not going anywhere, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[9,101,37,15],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/840"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=840"}],"version-history":[{"count":17,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/840\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/840\/revisions\/842"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}