Google Appengine Logging问题

时间:2015-05-27 01:08:08

标签: java google-app-engine servlets logging

感谢您对伐木的建议。如我所说, 我尝试将自己的过滤器类包括在内 logging.properties文件:

这是我的appengine-.xml文件,指向 logging-properties文件:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>uthreee</application>
  <version>1</version>

  <!--
    Allows App Engine to send multiple requests to one instance in parallel:
  -->
  <threadsafe>true</threadsafe>

  <!-- Configure java.util.logging -->
  <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
  </system-properties>

  <sessions-enabled>true</sessions-enabled>

</appengine-web-app>

这是logging-properties文件

# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
# 
# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#
java.util.logging.FileHandler.filter=F

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

而且,这是F.java

import java.util.logging.Filter;
import java.util.logging.LogRecord;

public class F implements Filter {
public boolean isLoggable(LogRecord lr) {
String Str = lr.getSourceClassName();
Str = Str.toUpperCase();
int pos1;
pos = Str.indexOf("STATUS");
pos1 =
System.out.println ("pos "+pos);
if (pos>=0) {
  return false;
}
else {
  return true;
}
}}

这是我想要抑制的日志信息:

2015-05-28 18:00:12.207 /api/get/status?_=1432861201589 200 19ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0 module=default version=1
I 2015-05-28 18:00:12.196 StatusServlet doGet: entering status servlet 1
I 2015-05-28 18:00:12.196 GenerationUtil TimerOK: Timer OK d:Fri May 29 01:00:12 UTC 2015 e: Fri May 15 14:47:30 UTC 2015Logical:true
D 2015-05-28 18:00:12.200 GenerationUtil currentSizeOfGeneration: FINE: Generation 1 currently has 10 chromosomes.
I 2015-05-28 18:00:12.200 GenerationUtil checkForQuorum: check quorum returning true
I 2015-05-28 18:00:12.200 StatusServlet doGet: TIMER OK true Q true
I 2015-05-28 18:00:12.200 StatusServlet doGet: HERE C
I 2015-05-28 18:00:12.200 GenerationUtil getCount: DEBUG: get Count status (ga) = 1 Key|generation(1)|
D 2015-05-28 18:00:12.206 GenerationUtil getCount: DEBUG: gcf; count 2
D 2015-05-28 18:00:12.206 GenerationUtil getCount: returning for gen1 value is 2
I 2015-05-28 18:00:12.206 GenerationUtil checkForSufficientRatings: DEBUG: check for Sufficient Ratings 1 count 2quorum 4
I 2015-05-28 18:00:12.206 GenerationUtil checkForSufficientRatings: DEBUG: insufficient ratings , returning false
I 2015-05-28 18:00:12.206 StatusServlet doGet: DEBUG:1 false

1 个答案:

答案 0 :(得分:0)

LogManager类加载器can't see your custom filter class。 logging.properties实际上只适用于安装标准处理程序和在GAE中设置日志级别。如果要安装自定义过滤器,则必须使用ServletContextListener编写代码手动安装过滤器。