Ladan Ladan - 7 months ago 11
Java Question

how to seprate the jetty.logs from solr.logs?

I using jetty as my container and I set up solr inside it, I using log4j.properties for my logging,when I used jetty standalone I can see my jetty logs ,but when I using solr an d log4j I only see solr.log file that all my jetty and solr logs are mixed in it,and my jetty.logs file created at the same time but it is empty,how can I separate the solr and jetty logs?
this is my log4j.properties:

# Logging level
solr.log=logs
log4j.rootLogger=INFO, file, CONSOLE


log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x [%X{collection} %X{shard} %X{replica} %X{core}] \u2013 %m%n




#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9

#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; [%X{collection} %X{shard} %X{replica} %X{core}] %C; %m\n

log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN

#set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF

Answer

This is how you can separate Solr and Jetty logs and write them into separate files using additivity:

log4j.additivity.org.apache.solr=false
log4j.additivity.org.eclipse=false


log4j.logger.org.apache.solr=INFO, SOLR
log4j.logger.org.eclipse=INFO, JETTY