${tomcat_home}/conf/server.xml.${tomcat_home}/logs.TdsMonitor tool, you will need to change the default configuration of the AccessLogValve.TdsMonitorprefix, suffix, and pattern attributes of the AccessLogValve element.Using your favorite editor open ${tomcat_home}/conf/server.xml:
$ vi server.xml
Locate the AccessLogValve contained in the Host element (should be near the bottom of the file):
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
Change the prefix and suffix attributes to customize the access log name. (The TdsMonitor tool looks for log files to begin with access.)
prefix="access." suffix=".log"
To provide more useful information about who is accessing the TDS, change the pattern element to customize the format of each log entry:
pattern="%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %D"
When you are finished with your edits, the AccessLogValve should look something like the following:
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="access."
suffix=".log"
pattern="%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %D" />
Restart Tomcat and verify an access log has been generated in the ${tomcat_home}/logs/ directory:
$ ls -l /home/tds/workshop/apache-tomcat-7.0.32/logs -rw-r--r-- 1 tds ustaff 2444 Oct 21 12:26 access.2012-10-21.log -rw-r--r-- 1 tds ustaff 7470 Oct 21 12:26 catalina.2012-10-21.log -rw-r--r-- 1 tds ustaff 7583 Oct 21 12:26 catalina.out -rw-r--r-- 1 tds ustaff 0 Oct 21 12:26 host-manager.2012-10-21.log -rw-r--r-- 1 tds ustaff 2160 Oct 21 12:26 localhost.2012-10-21.log -rw-r--r-- 1 tds ustaff 0 Oct 21 12:26 manager.2012-10-21.log
The access log entry format we are using is almost identical to the standard combined logging format with an addition: the %D which is used for documenting the Time taken to process the request, in millis will appear at the end of each log entry:
pattern="%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %D"
For more information on access log format configuration, see the Tomcat Valve Component Documentation.
The above pattern makes use of the following codes:
%h - Remote host name (or IP address if resolveHosts is false)
%l - Remote logical username from identd (always returns '-')
%u - Remote user that was authenticated (if any), else '-'
%t - Date and time, in Common Log Format
%r - First line of the request (method and request URI)
%s - HTTP status code of the response
%b - Bytes sent, excluding HTTP headers, or '-' if zero
%D - Time taken to process the request, in millis
The above pattern translates into:
127.0.0.1 - admin [21/Oct/2012:12:31:59 -0600] "GET /manager/html HTTP/1.1" 200 17578 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.7) Gecko/20120829 Firefox/10.0.7" 8
Another way of looking at it:
| Remote host |
127.0.0.1
|
| Remote logical username from identd |
-
|
| Authenticated user |
admin
|
| Time and date of request |
[21/Oct/2012:12:31:59 -0600]
|
| HTTP request method |
GET
|
| Request URI |
/manager/html
|
| Protocol used |
HTTP/1.1
|
| HTTP server response |
200
|
| Bytes transferred |
17578
|
| Referer |
-
|
| User Agent |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.7) Gecko/20120829 Firefox/10.0.7
|
| Response time (in millis) |
8
|
${tomcat_home}/content/thredds/logsThere are two locations of log files you will reference:
${tomcat_home}/logs/ is where you go to look at Tomcat-generated log files; andThe log files generated by the TDS are located in the ${tomcat_home}/content/thredds/logs directory:
| Log file | Data the file contains |
|---|---|
threddsServlet.log
|
Each request that the TDS responds to gets logged here, including errors and warnings that are associated with a request. |
serverStartup.log
|
As TDS starts up, it logs messages heren (usually only interesting if TDS is failing to start). |
models.log
|
Contains log messages specific to gridded model data, especially GRIB data. |
cache.log
|
Cache scour messages are kept here (only interesting if you are having problems with cache directories getting too large). |
featureCollectionScan.log
|
Contains log messages about feature collection scanning (only used if you use feature collections). |
catalogInit.log
|
Errors and warnings in your catalog configuration files are shown here. |
threddsServlet.logthreddsServlet.log.<yyyy-mm-dd-HH> pattern.threddsServlet.log to the TDS development team when seeking support.threddsServlet.log log formatthreddsServlet.log.Navigate to the unpacked thredds directory in ${tomcat_home}/webapps/WEB-INF, and view the log4j.xml:
$ cd /home/tds/workshop/apache-tomcat-7.0.32/webapps/thredds/WEB-INF $ less log4j.xml
The TDS uses the OpenSource Apache Log4J library (hence, the name of the file: log4j.xml).
Find the first uncommented Appender element with a name of threddsServlet and a class of org.apache.log4j.DailyRollingFileAppender, and note the ConversionPattern:
<appender name="threddsServlet" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${tds.log.dir}/threddsServlet.log"/>
<param name="DatePattern" value=".yyyy-MM-dd-HH"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS Z} [%10r][%8X{ID}] %-5p - %c - %m%n"/>
<!--param name="ConversionPattern" value="%d{ISO8601} [%10r - %10X{ID}] %-5p - %c - %m%n"/-->
</layout>
</appender>
threddsServlet.log file.The ConversionPattern parameter specifies the Log4J pattern used to format the entries of the threddsServlet.log file:
value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS Z} [%10r][%8X{ID}] %-5p - %c - %m%n"
Log4J libraryFor more information on the Log4J library, consult the online documentation.
The above pattern makes use of the following Log4J codes:
%d{yyyy-MM-dd'T'HH:mm:ss.SSS Z} - Date and time
%10r - Time, in millis, since Tomcat startup
%8X{ID} - Transaction ID
%-5p - Logging level (options are DEBUG, INFO, WARN, ERROR, and FATAL)
%c - Location in the TDS code where the message was generated
%m - Content of the log message
%n - Newline character
The above pattern translates into:
2012-10-21T12:26:23.727 -0600 [ 5887][ 8] INFO - threddsServlet - Remote host: 127.0.0.1 - Request: "GET /thredds/catalog/testAll/catalog.html?dataset=testDatasetScan/2004050412_eta_211.nc HTTP/1.1"
Another way of looking at it:
| Time and date |
2012-10-21T12:26:23.727 -0600
|
| The number of milliseconds since the server was started |
[ 5887]
|
| Request ID |
[ 8]
|
| Logging level |
INFO
|
| Location in the TDS code where the message was generated |
threddsServlet
|
| Content of the log message |
Remote host: 127.0.0.1 - Request: "GET /thredds/catalog/testAll/catalog.html?dataset=testDatasetScan/2004050412_eta_211.nc HTTP/1.1"
|
threddsServlet.logDEBUG, WARN, ERROR, etc.).The main message in a start of transaction log message includes:
For example:
... Remote host: 128.117.140.75 - Request: "GET /thredds/catalog.html HTTP/1.1"
The main message in a end of transaction log message includes:
For example:
... Request Completed - 200 - 3403 - 1
Most end of transaction messages include a status code that matches a standard HTTP status code. However, when the client breaks the connection or a request is forwarded to another TDS internal service, one of three TDS specific status codes are used:
"1000 (Client Abort)" - the connection to the client was broken;"1001 (Forwarded)" - the request was forwarded to another TDS internal service; or"1002 (Forward Failed)" - an attempt was made but failed to forward the request to another TDS internal service.If the request is forwarded successfully, another set of transaction messages should be initiated with the ending message containing a standard HTTP status code. If forwarding the request fails, another set of transaction message may or may not be initiated and the entry in the access log will probably either log a 404 (File Not Found) or a 500 (Internal Server Error) HTTP status code.
threddsServlet.log dataHere is an example of some log messages from a request that resulted in error messages:
2012-10-22T17:31:52.705 -0600 [ 5790][ 4] INFO - threddsServlet - Remote host: 127.0.0.1 - Request: "GET /thredds/dodsC/badAggy.html HTTP/1.1"
2012-10-22T17:31:52.752 -0600 [ 5837][ 4] ERROR - thredds.server.opendap.OpendapServlet - path= /badAggy.html
java.lang.IllegalStateException: There are no datasets in the aggregation DatasetCollectionManager{ collectionName='/data/model/**/.nc' recheck=null
dir=/data/model/ filter=WildcardMatchOnPath{wildcard=*.nc$ regexp=.*\.nc$}
at ucar.nc2.ncml.Aggregation.makeDatasets(Aggregation.java:475)
at ucar.nc2.ncml.Aggregation.finish(Aggregation.java:401)
...
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
2012-10-22T17:31:52.755 -0600 [ 5840][ 4] INFO - threddsServlet - Request Completed - 500 - -1 - 50
Log messages from multiple requests can be interspersed in the log file.
In the above example, note:
500 (Internal Server Error) .threddsServlet.log.threddsServlet.log. We are going to tell the TDS to aggregate multiple datasets into a single dataset, BUT we are erroneously going to configure it to scan a directory that doesn't exist.Open up ${tomcat_home}/content/thredds/catalog.xml and add the following:
<dataset name="badAggy" ID="badAggy" urlPath="badAggy">
<metadata inherited="true">
<serviceName>odap</serviceName>
</metadata>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<aggregation dimName="time" type="joinExisting">
<scan location="/data/model/" suffix=".nc" />
</aggregation>
</netcdf>
</dataset>
Stop and restart Tomcat and view the result of your addition the TDS main catalog: http://localhost:8080/thredds/catalog.html. You should see a new dataset listed with the name of badAggy:
Click on the badAggy dataset and try to access it via OPeNDAP:
The result should be a 500 (Internal Server Error) (which is the error we sought to create):
grep command to find out which threddsServlet.log file contains the error message:$ cd /home/tds/workshop/apache-tomcat-7.0.32/content/thredds/logs $ grep ERROR threddsServlet.log*
threddsServlet.log file which contains the error message and find all the message transaction entries that correspond to that error.threddsServlet.log resulting in a 404 (File Not Found)?${tomcat_home}/content/thredds/catalog.xml and stop/restart Tomcat.There are a variety of OpenSource and commercial log analysis packages you may wish to employ.
manager application in your browser: http://localhost:8080/manager/html/ and login.JVisualVM and JConsoleJVM monitoring tools$JAVA_HOME/bin).JVisualVM or JConsoleJVisualVM or JConsole to track the JVM running Tomcat.Move into the $JAVA_HOME/bin directory and invoke either jvisualvm or jconsole:
$ cd /home/tds/workshop/jdk1.7.0_09/bin $ ./jvisualvm
or
$ cd /home/tds/workshop/jdk1.7.0_09/bin $ ./jconsole
manager application and examine the result in the CPU usage, Class loading, live Threads count, Heap memory and PermGen memory.PermGen memory limit? Try to drive the PermGen to it's limit via the manager application. Are you successful?