弹性搜索:无法导入记录器(答案适用于其他导入) [英] Elasticsearch: Unable to import logger (answer applies to other imports)

查看:232
本文介绍了弹性搜索:无法导入记录器(答案适用于其他导入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标

使用Elasticsearch的记录器功能更好地调试服务器端Groovy脚本代码。

To use Elasticsearch's logger functionality to better debug server-side Groovy script code.

问题摘要

无法导入 org.elasticsearch.common.logging。 code>

Unable to import org.elasticsearch.common.logging.*

详细信息


  • 使用Elasticsearch 2.3

  • 存储在 / etc / elasticsearch / scripts 和Java客户端中的脚本已经能够通过 Client.update()。也就是说,文件夹位置应该是正确的。我已经看到建议将代码放在 elasticsearch / config / scripts 中,这对我来说实际上不起作用)

  • 尝试此解决方案,即:

  • Using Elasticsearch 2.3
  • Scripts stored in /etc/elasticsearch/scripts and Java client has been able to access them successfully via Client.update(). That is, the folder location should be correct. I've seen suggestions to place code in elasticsearch/config/scripts, which actually didn't work for me)
  • Tried this solution, that is:

import org.elasticsearch.common.logging。*

ESLogger logger = ESLoggerFactory。 getLogger('myscript')

但是,Elasticsearch日志显示编译器投诉:
无法解析类org.elasticsearch.common.logging.ESLogger

But the Elasticsearch log shows a compiler complaint: unable to resolve class org.elasticsearch.common.logging.ESLogger

我检查了源代码GitHub here 并且ESLogger类在那里。所以我不知道为什么会发生这种情况。

I checked the source code on GitHub here and the ESLogger class is there. So I don't know why this is happening.

有没有人有意获得 import 的工作?

Does anyone have advice on getting the import to work?

推荐答案

原因是配置哪些您希望脚本能够访问的课程

为了能够在脚本中使日志记录工作,我已经定义了自己的策略文件并将其设置为JAVA_OPTS或者甚至在启动命令中为 -Djava.security.policy = file:/// D:/ES/elasticsearch-2.3.1/my.policy my.policy 文件的最小内容应为:

To be able to make logging work in scripts I have defined my own policy file and set it JAVA_OPTS or even in the startup command as -Djava.security.policy=file:///D:/ES/elasticsearch-2.3.1/my.policy. The minimum content of the my.policy file should be:

grant {
    permission org.elasticsearch.script.ClassPermission "org.elasticsearch.common.logging.*";
    permission org.elasticsearch.script.ClassPermission "org.apache.log4j.*";
};

当然,您需要重新启动ES才能使更改生效。

Of course, you need to restart ES for the changes to be effective.

这篇关于弹性搜索:无法导入记录器(答案适用于其他导入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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