Tuesday, April 7, 2009

Getting Thread Dumps or StackTraces

Stack trace can be obtained by issuing the following command

jstack <processid>

The output can also be redirected into any file.

Ref : http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstack.html

The thread dumps also can be obtained by the following command

kill -3

The thread dump will be appended to the application logs.

(Redirect the standard out (stdout) of the java command to a file. When you send a SIGQUIT signal to the java process, a thread dump is sent to the stdout)

To understand and analyse the thread dumps refer the following

http://weblogs.java.net/blog/bhaktimehta/archive/2007/05/obtaining_and_a.html

Configuring Logging for Tomcat on Eclipse

When tomcat is added as a server under Eclipse thw logs are displayed on the console and it never comes under the logs of tomcat neither in eclipse workspace.

It can be configured to do so by

Double Clicking the newly added server in the Servers menu

1. In General Information

Click Open Launch Configurations - >
-> Add the required arguments in the argument tab ,
-> and in the Common tab you can mention weather the output the to be on the console or piped int o any other log file ion the disk.

Refer this to enable JULI logging on the Server Instance

http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F

2. In the Server Location - you can choose User Tomcat Installation which will take control on the tomcat installation directory and all application under it will also be deployed

Enabling Access Logs on Tomcat 6

Tomcat 6 has a new feature which logs access logs. This can be easily enabled by uncommenting the required code in the conf/server.xml.

<valve classname="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolvehosts="false">
</valve>

This can be embedded for the Host or per context basis

 
Free Domain Names @ .co.nr!