When working on the fulltext indexing for the Elasticsearch integration for Neos I recently needed a way to debug what was going on inside a Groovy script we use. It's relatively simple, if you know how…
As soon as such a need arises, finding the solution with a quick internet search yields a quick result along these lines:
import org.elasticsearch.common.logging.*;
ESLogger logger=ESLoggerFactory.getLogger('some.identifier');
logger.info('Ah, a log message!');
This should log to the Elasticsearch server log similar to this:
[2016-10-19 18:21:09,534][INFO ][some.identifier] Ah, a log message!
While this is correct, you probably need one more adjustment if you configured Elasticsearch according to the instructions for the Flowpack adaptor. Without that adjustment, you will see GroovyScriptCompilationException errors in the Data/Logs/ElasticSearch.log.
Since what is allowed to be called in Groovy is restricted, you need to add the logging bits (org.elasticsearch.common.logging.ESLoggerFactory and org.elasticsearch.common.logging.ESLogger) to the sandbox receiver whitelist:
script.groovy.sandbox.receiver_whitelist: java.util.Iterator, java.lang.Object, java.util.Map, java.util.Map$Entry, org.elasticsearch.common.logging.ESLoggerFactory, org.elasticsearch.common.logging.ESLogger
Now restart your Elasticsearch instance and your log messages will show up as expected.
Kommentare