On 3/28/2018 9:47 AM, Vincenzo D'Amore wrote:
I'm struggling to add http remote ip address in solr (jetty) log file.
I've tried to modify the server/resources/log4j.properties file, which
seems to control the output log format, but I'm unable to understand how to
add in ConversionPattern the proper ip address field.
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS}
%-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
I don't think this can be done in solr.log without changes to the Solr
code. As far as I know, there is no option you can give to log4j to log
the IP address. Solr doesn't keep track of the IP address, so it
definitely isn't available to the logging framework.
Solr would need to *get* the remote address from the servlet container,
probably in SolrDispatchFilter, and pass that information down the stack
to SolrCore, where requests are actually logged. The API is not
designed to pass IP addresses, so a mechanism would probably have to be
created.
I would actually like to see this feature, so opening an enhancement
issue in Jira is advisable.
The request log in Jetty can give you this information. In
server/etc/jetty.xml, there is a config section already there for a
request log, but it is commented so it's not active.
Thanks,
Shawn