I have a Java application which uses Solrj to accessa remote solr server. It is built with Maven and Spring. It is set up as follows.
Instantiate solr server object and wire it into a an AutocompleteSolrTemplate bean (custom):
<solr:solr-server id="solrServer" url="${solr.host}" maxConnections="1500" timeout="2000"/>
<bean id="customSolrTemplateEncounter" class="com.domain.common.solr.AutocompleteSolrTemplate">
<constructor-arg ref="solrServer"/>
<constructor-arg value="encounterAutocomplete"/>
</bean>
public class AutocompleteSolrTemplate extends SolrTemplate {
private static final Logger log = Logger.getLogger(AutocompleteSolrTemplate.class);
public AutocompleteSolrTemplate(final SolrServer solrServer, final String core) {
super(solrServer, core);
}
final QueryResponse runSolrQuery(final SolrQuery solrQuery) {
return execute(new SolrCallback<QueryResponse>() {
@Override
public QueryResponse doInSolr(final SolrServer solrServer) throws SolrServerException, IOException {
log.debug("Solr request:\n\t" + RequestUtil.URLDecode(solrQuery.toString()));
return solrServer.query(solrQuery, METHOD.POST);
}
});
}
}
So I can easily log the solr request as above, but how do I log the full solr URL? The host is a property that gets replaced on application load ${solr.host}, but it would be nice for debugging purposes to log the full URL including the host.
Any help?
You are creating the AutocompleteSolrTemplate
as:
<bean id="customSolrTemplateEncounter" class="com.domain.common.solr.AutocompleteSolrTemplate">
<constructor-arg ref="solrServer"/>
<constructor-arg value="encounterAutocomplete"/>
</bean>
Why cant you just simply add one more constructor arg and pass the solr url in it so that you can log it as you need!!
public AutocompleteSolrTemplate(final SolrServer solrServer, final String core, final String solrUrl) {
//Log the URL here!!
super(solrServer, core);
}