ive tried using logger object. the script code is :
> import org.elasticsearch.common.logging.*;
> // ESLogger el;
>ESLogger logger=ESLoggerFactory.getLogger('test_logger');
// logger.info('SCRIPT_LOG:::This is a log message');
and i got the error message:
{
"error": "QueryParsingException[[goods_v1] script_score the script could not be loaded]; nested: ElasticsearchIllegalArgumentException[Unable to find on disk script test_logger]; ",
"status": 400
}
ive had a test for the code, it seems that the error is from line:
I put the above one by one as well as both in the elasticsearch.yml file, restarted the node - no luck (I've re-deployed the node)
I created a .java.policy in node's root and disabled filtering. Still, didn't work
I added the grant permissions in java.policy in JAVA Home - no luck
All these give me and error at compilation as ESLogger was not found.
Also, from what I understood from @Sergey_Novikov's answer, I was expecting to be able to use logger.info('arg') directly from the script, as it is but it didn't work -compilation is fine but I am getting illegal argument exception when executing the script. (I think the error may be misleading and the logger is not actually available)
I finally managed to get it to work by granting permissions to import org.elasticsearch.common.logging.*; in elasticsearch/modules/lang-groovy/plugin-security.policy
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.