是否可以在 AppEngine 上向 JUL 添加处理程序?
我有一个使用 Java 的 AppEngine 应用程序。 我正在使用 JUL (java.util.logging) 来记录服务器端日志。 我正在创建一个门面调用 CustomLogger,其中它使用工厂在构造函数中创建一个 JUL 记录器:
@Inject
public CustomLogger( EmailLoggingHandler handler ){
this.logger = Logger.getLogger( "ServerLogger" );
logger.addHandler( handler );
}
CustomLogger 的实例绑定为 eagerSingleton,这意味着每个 Guice 实例只会实例化该类的一个实例。 一切都正常,直到我注入自定义记录器(EmailLoggingHandler),它也是依赖树的一部分,作为 eagerSingleton。
@Inject
public EmailLoggingHandler( SendEmailHelper emailHelper ){
this.emailHelper = emailHelper;
setLevel(Level.SEVERE);
}
我收到的错误:
Error injecting constructor, java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
有人知道为什么会发生这种情况吗?
I have an AppEngine application with Java.
I am using JUL (java.util.logging) to log the server side logs.
I am creating a facade call CustomLogger in which it creates a JUL logger in the constructor using the factory:
@Inject
public CustomLogger( EmailLoggingHandler handler ){
this.logger = Logger.getLogger( "ServerLogger" );
logger.addHandler( handler );
}
Instance of CustomLogger is bind as eagerSingleton meaning only one instance of this class will ever be instantiated per Guice instance.
Everything was working until I injected the custom logger (EmailLoggingHandler) which is also part of dependency tree as a eagerSingleton.
@Inject
public EmailLoggingHandler( SendEmailHelper emailHelper ){
this.emailHelper = emailHelper;
setLevel(Level.SEVERE);
}
The error I am getting:
Error injecting constructor, java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
Does anyone have any idea why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我尝试将处理程序挂接到 AppEngine 上的 JUL 时,我遇到了同样的问题。我通过避免调用 setLevel() 并仅使用我自己的级别变量来解决这个问题:
I had the same problem when I tried to hook my handler into JUL on AppEngine. I solved it by avoiding any calls to
setLevel()
and just using my own level variable: