wiki:cs122b-2019-winter-project1-logging

Logging in MySQL and Tomcat

To develop this multi-tier application, it is very important for you to understand what's happening in each tier. Whenever you have the question "why doesn't my application work?", the first thing you should do is to use the logging of MySQL and Tomcat to understand what each tier has received, and whether there is any error. This page provides instructions on how to enable and analyze logging of MySQL and Tomcat, on both the development machine and the production/AWS machine.


1. MySQL Logging (AWS and Dev)

  • By default MySQL doesn't enable logging. To enable it, run the following:
    shell> mysql -u root -p
    mysql> SET GLOBAL general_log = 'ON';
    mysql> exit
    
  • Run the following command to find MySQL file log file:
    shell> mysql -u root -p -se "SHOW VARIABLES" | grep -e log_error -e general_log -e slow_query_log
    

Pay attention to the path in the general_log_file line. For example:

general_log_file	/usr/local/mysql/data/dhcp-v044-069.log
  • Monitor the ".log" files under this folder. In Linux and Mac, the following is an example command using "tail":
shell> sudo tail -f /usr/local/mysql/data/*.log

2. Tomcat Logging (AWS)

By default, Tomcat logging is enabled.

  • Monitor log files by running the command:
    sudo tail -f HOME_OF_TOMCAT/logs/*
    
  • For instance:
    sudo tail -f /home/ubuntu/tomcat/logs/*
    

3. Tomcat Logging (Dev machine + Eclipse)

  • After Eclipse starts, go to the Servers view and double-click the Tomcat server you're running.

  • You will find a window like the image below. Click the link Open launch configuration.

  • You will find a dialog window like the image below.

  • Click on the Arguments section. The log files are stored in the folder logs of the path -Dcatalina.base.
  • Change the directory to that folder and monitor the files as your browser sends requests to Tomcat. On Ubuntu or MacOS, you can run the following command : tail -f *.
Last modified 18 months ago Last modified on Jan 15, 2019 1:27:13 PM

Attachments (3)

Download all attachments as: .zip