5 Replies Latest reply on Aug 24, 2011 8:05 PM by max010

    Logging configurations

    max010

      Hi,

       

      I am trying to create a solr-.yyyy-MM-dd.log file in the /standalone/log directory.

       

      From the SOLR wiki I have to add:

       

      <logger category="org.apache.solr">

                                 <level name="INFO"/>

      </logger>

       

      in the standalone.xml.

       

      Do I need to create a new logger?

       

      In the standalone.xml the <root-logger> is defined:

       

      <root-logger>

                      <level name="INFO"/>

                      <handlers>

                          <handler name="CONSOLE"/>

                          <handler name="FILE"/>

       

                      </handlers>

                  </root-logger>

       

      How do I create a new logger that logs output to the solr-.yyyy-MM-dd.log file?

       

      Should I do this below?

       

      <solr-logger>

                      <level name="INFO"/>

                      <handlers>

                           <handler name="SOLRFILE"/>

       

                      </handlers>

                  </solr-logger>

       

      Can anyone please help me with this issue?

       

      Thanks,

       

      Max

        • 1. Re: Logging configurations
          prasad.deshpande

          You need to create a handler first somethig like this

           

                  <periodic-rotating-file-handler name="SOLRFILE" autoflush="true">
                      <level name="DEBUG"/>
                      <formatter>
                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                      </formatter>
                      <file relative-to="jboss.server.log.dir" path="solr.log"/>
                      <suffix value=".yyyy-MM-dd"/>
                      <append value="true"/>
                  </periodic-rotating-file-handler>

           

          and a logger like

           

                  <logger category="org.apache.solr">
                      <level name="INFO"/>
                      <handlers>
                          <handler name="SOLRFILE"/>
                      </handlers>
                  </logger>

           

          This will create file solr.log in the log directory. Also, it as the date changes, it will add suffix yyyy-MM-dd to the file. So file solr.log will always be for current date.

          • 2. Re: Logging configurations
            max010

            Thanks Prasad,

             

            I have created the handler and logger as you said but I still do not get a solr.log file.

             

            In the server.log I get the following warnings:

             

            01:06:27,313 ERROR [stderr] (MSC service thread 1-1) log4j:WARN No appenders could be found for logger (org.apache.solr.core.SolrResourceLoader).

            01:06:27,313 ERROR [stderr] (MSC service thread 1-1) log4j:WARN Please initialize the log4j system properly.

            01:06:27,314 ERROR [stderr] (MSC service thread 1-1) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

             

            The jars I have in the WEB-INF/lib used for logging are:

             

            log4j-1.2.16.jar

            jcl-over-slf4j-1.6.1.jar

            slf4j-api-1.6.1.jar

            slf4j-log4j12-1.6.1.jar

             

            I am not quite sure what I am missing.

             

            Any suggestions?

            • 3. Re: Logging configurations
              jaikiran

              So you are using log4j and not JBoss logging. You will have to create a log4j.xml file with the solr appenders/loggers in that file and package the log4j.xml in your application (.war/WEB-INF/classes folder)

              • 4. Re: Logging configurations
                prasad.deshpande

                As Jaikiran suggested, also have a look at this thread. http://community.jboss.org/thread/171288?tstart=0

                • 5. Re: Logging configurations
                  max010

                  I have added a log4j.properties in the solr.war/WEB-INF/classes directory and I got a solr.log.

                   

                  The log4j.properties looks like this:

                   

                  log4j.rootLogger=INFO, SOLR

                  log4j.appender.SOLR=org.apache.log4j.DailyRollingFileAppender

                  log4j.appender.SOLR.file=/opt/jboss-as-web-7.0.0.Final/standalone/log/solr.log

                  log4j.appender.SOLR.datePattern='.'yyyy-MM-dd

                  log4j.appender.SOLR.layout=org.apache.log4j.PatternLayout

                  log4j.appender.SOLR.layout.conversionPattern=%d %p [%c{3}] - [%t] - %X{ip}: %m%n

                   

                  Thanks everyone.