找不到Google Cloud Logging处理程序 [英] Google Cloud Logging Handler Not Found

查看:103
本文介绍了找不到Google Cloud Logging处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将记录器指向google cloud日志记录处理程序时,我的Google App Engine本地开发服务器返回了classdef not found异常,该如何解决呢?

My google app engine local development server returns a classdef not found exception when I point the logger to google clouds logging handler, how do I fix this?

INFO: Dev App Server is now running
Can't load log handler "com.google.cloud.logging.LoggingHandler"
java.lang.ClassNotFoundException: com.google.cloud.logging.LoggingHandler
java.lang.ClassNotFoundException: com.google.cloud.logging.LoggingHandler
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.util.logging.LogManager$5.run(LogManager.java:965)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.loadLoggerHandlers(LogManager.java:958)
    at java.util.logging.LogManager.addLogger(LogManager.java:1165)
    at java.util.logging.LogManager.demandLogger(LogManager.java:556)
    at java.util.logging.Logger.demandLogger(Logger.java:455)
    at java.util.logging.Logger.getLogger(Logger.java:502)
    at coffee.weneed.chat.CoffeeChat.<clinit>(CoffeeChat.java:37)
    at coffee.weneed.chat.kik.KikServlet.doGet(KikServlet.java:18)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at ...

我的logging.properties:

my logging.properties:

.level = INFO
io.grpc.netty.level=INFO
sun.net.level=INFO

coffee.weneed.chat.CoffeeChat.handlers=com.google.cloud.logging.LoggingHandler,java.util.logging.ConsoleHandler
com.google.cloud.logging.LoggingHandler.log=coffee_chat
com.google.cloud.logging.LoggingHandler.level=INFO

com.google.cloud.logging.LoggingHandler.flushLevel=SEVERE
com.google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s

和我的系统属性:

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

我已包括将云登录到Maven Deps,已安装了Cloud Maven插件.我只是不太了解为什么它不能加载该类.

I have included the cloud logging into the maven deps, the cloud maven plugin is installed. I just can't quite find out why it won't load the class.

推荐答案

针对GAE的功能请求.这也是JDK的一个已知问题,如 JDK-6878454:LogManager类加载与Java不一致EE最佳做法.

You have to use code to install a custom handler in GAE. This is described as a feature request for GAE. It is also a known issue with the JDK as JDK-6878454: LogManager class loading inconsistent with Java EE best practices.

问题是LogManager使用系统类加载器来定位处理程序,但是您的代码位于Web应用程序类加载器中,该应用程序将是子类加载器.子类加载器可以在父类中找到类,但不能反过来.这是您 java.lang.ClassNotFoundException 的原因.

The issue is that the LogManager uses the system class loader to locate handlers but your code is located in a web app class loader which will be a child class loader. The child class loader can locate classes in the parent but not the other way around. This is the cause of your java.lang.ClassNotFoundException.

您可以按照此示例设置自定义处理程序设置在GAE中.这使用 ServletContextListener 获得对正确的类加载器的访问.

You can follow this example setting up a custom handler setup in GAE. This uses a ServletContextListener to gain access to the correct class loader.

这篇关于找不到Google Cloud Logging处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆