CS6320:  SW Engineering of Web Based Systems

 

Google App Engine -- Logging

  • DEFAULT LOGGING DONE BY GAE: App Engine logs all incoming requests for your application, including application requests, static file requests, and requests for invalid URLs (so you can determine whether there is a bad link somewhere).

    • logs the date and time

    • IP address of the client

    • URL requested (including the path and parameters)

    • the domain name requested,

    • the browser's identification string (the "user agent"),

    • the referring URL if the user followed a link,

    • HTTP status code in the response returned by the app or by the frontend.

    • TIMMING:

      • amount of time it took to handle each request

      • amount of "CPU time" that was spent handling the request with size of the response

        • The CPU time measurement is particularly important to watch because requests that consistently consume a large amount of CPU may be throttled, such that the CPU use is spread over more clock time. This can effect your $$ charges

 

Loggin from your code

  • occurrence of notable events and data using a logging API.

  • Logging a message associates a line of text with the request that emitted it, including all of the data logged for the request. Each message has a log level indicating the severity of the message to make it easier to find important messages during analysis.

App Engine "Levels" of Logging

  • debug

  • info

  • warning

  • error

  • critical.

How to View your Logs

To access the Logs Viewer:

  1. Open your project in the Developers Console.

  2. Select Logging



  3. If your app runs in a Managed VM and writes custom logs, select the desired log name.

 

  • Here are the results

  • You can also download your log data for offline analysis and recordkeeping.

 

 

GAE: Logging in Java

java.util.logging package

         import java.io.IOException;
         import javax.servlet.http.*;
         import java.util.logging.Logger;
         public class LoggingServlet extends HttpServlet {

           private static final Logger log = Logger.getLogger(LoggingServlet.class.getName());

           public void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException {
                  log.finest("finest level"); // DEBUG
                  log.finer("finer level"); // DEBUG
log.fine("fine level"); // DEBUG
log.config("config level"); // DEBUG
log.info("info level"); // INFO
log.warning("warning level"); // WARNING
log.severe("severe level"); // ERROR
System.out.println("stdout level"); // INFO
System.err.println("stderr level"); // WARNING
}
}

 

java.util.logging --- LEVELS GAE Corresponding LEVELS
finest, finer, fine debug
info info
warning warning
severe error
not a level --these are exceptions not caught by servlet. critical
System.out info
System.err warning

What happens to System.out messages in Java   

----> are added to log at "info" level   

What happens to System.error messages in Java    

---- are added to log at "warning" level    

Java in GAE - setting up loag levels using configuration file

  1. create a resource file, such as war/WEB-INF/logging.properties, containing a line like this:
    .level=INFO
    You can configure the log level on a per-class basis by adding lines like this with the
    package path before the .level.
  2. This allows you to turn on fine-grained messaging for some components without turning it on for all components. For example, the Google
    Plugin for Eclipse creates a logging.properties configuration file with per-component settings for DataNucleus, the JDO/JPA interface package, so you can use verbose logging
    for your app code without cluttering up your output with messages from the DataNucleus component.
  3. Be sure to use the logging level name (such as FINEST) and not the App Engine level name for values in logging.properties. App Engine log levels only affect how messages are represented in the Admin Console.

    config file for loggin


  4. POINT system to this configuration file in appengineweb.xml by including a <system-properties> element in your appengineweb.
    xml file, like so:
    <system-properties>
         <property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
    </system-properties>

    point to loggin config prop file



  5. NOTE Google Plugin for Eclipse creates the above for you.
  6.  


When running in the development web server, log messages are written to the console,
and text written to the standard streams is written to the corresponding streams for the
server.
In Eclipse, these messages appear in the Console pane.

eclipse loggin messages in console

© Lynne Grewe