开发者

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 G开发者_如何学JAVAWT development mode container)? Is there some magic incantation I need to see my logging output?


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>


Plase change your WEB-INF/logging.properties file.

Add

    .level=INFO


Make sure you have the right log classes and logging level set up in your logging.properties file:

WEB-INF/logging.properties:

# Configure a file log for devserver
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
java.util.logging.FileHandler.pattern=/tmp/appengine-devserver.log
java.util.logging.FileHandler.limit=0  # no limit
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜