Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making log messages visible on Java GoogleAppEngine development server (used with GWT)

I am using java.util.logging.Logger to do my logging on my Java GoogleAppEngine app. This works peachily when the app is deployed. However, I am unable to see my log messages when running my app in the development server.

Salient additional details:

  • I'm running the app engine development server inside the GWT development mode container, not standalone.
  • I have a logging.properties configured, though it seems to make no difference (it works correctly in production with or without the logging.properties, and it does not work in development with or without the logging.properties).
  • If I use System.out.println on the development server, this is output to the terminal from which I ran the GWT development mode container. Obviously this is a usable workaround, but I would like logging to just work in both development and production mode.

Has anyone gotten logging working in development mode (with or without using AppEngine in conjunction with the GWT development mode container)? Is there some magic incantation I need to see my logging output?

like image 258
samskivert Avatar asked Nov 13 '10 19:11

samskivert


1 Answers

I had the same problem yesterday, but now it works for me.

Not sure what the change was, but I will post my configuration below so you can try it out (running GAE 1.3.8, no GWT but shouldnt matter).

Please note that the logs will appear in the console window (amongst the other server logging). I am not sure you can get it to log to files since the server is running in some kind of sandbox. I have only tested this configuration in my local environment, not uploaded.

WEB-INF/appengine-web.xml:

   <?xml version="1.0" encoding="utf-8"?>
   <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
      <!-- (omitted application,version from sample-->
      <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
      </system-properties>
   </appengine-web-app>

WEB-INF/logging.properties:

  # Set the default logging level for all loggers to WARNING
  #.level = WARNING
  #.level = ALL
  .level = INFO

logtest.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import=" java.util.logging.Logger"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="sv" xml:lang="sv">
<head>
</head>

<%
Logger logger = Logger.getLogger("org.whatever.Logtest");
logger.info("logtest info");
logger.warning("logtest warning");
logger.severe("logtest severe");


%>

<body>
Check the console for logging
</body>

</html>
like image 133
Brummo Avatar answered Nov 15 '22 13:11

Brummo