Skip to content

Instantly share code, notes, and snippets.

@zyjibmcn
Last active April 15, 2016 09:38
Show Gist options
  • Save zyjibmcn/f9995ea980d232424348ab0333a22b6b to your computer and use it in GitHub Desktop.
Save zyjibmcn/f9995ea980d232424348ab0333a22b6b to your computer and use it in GitHub Desktop.
apache solr + log4j configuration

配置Solr log4j

  1. 在Apache Tomee 1.7.4 下 可以通过指定log4j.configuration system properties来指定log4j.properties的位置。

    export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=path_to_log4j_properties"

    path_to_log4j_properties must be: **file:///**path

    拷贝SLF4J 等jar包到应用WEB-INF/lib下面,注意必须是应用下面,拷贝到$CATALINA_HOME/lib下是不生效的。

    jcl-over-slf4j-1.7.7.jar
    jul-to-slf4j-1.7.7.jar
    log4j-1.2.17.jar 
    slf4j-api-1.7.7.jar 
    slf4j-log4j12-1.7.7.jar
    
  2. 在Webshpere Liberty 8.5.5.* 下 在etc/jvm.options里设置-Dlog4j.configuration=path_to_log4j_properties 不生效。

    Always throws:
    
    log4j:WARN No appenders could be found for logger 
    log4j:WARN Please initialize the log4j system properly.
    
    

    只能通过library的方式:

    <application ...>
      <classloader>
        <privateLibrary id="solrExt">
          <folder dir="${shared.resource.dir}/log4jProperties" />
          <fileset dir="${shared.resource.dir}/solr-ext" includes="*.jar"></fileset>
        </privateLibrary>
      </classloader>
    </application>
    

    一开始我在etc/jvm.options里配置-Dlog4j.configuration=path_to_log4j_properties指向的路径, 不生效后,并未删除。然后配置library, 发现仍然不能生效。最后打开liberty的trace, 发现了-Dlog4j.configuration=path_to_log4j_properties指向的路径,猜测是发生了冲突。 然后删掉-Dlog4j.configuration=path_to_log4j_properties, 就成功了。

    Trouble shooting in server.xml:

    <logging  traceSpecification="com.ibm.ws.classloading.*=all:org.apache.solr.core.*=all" />
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment