0
votes

I'm trying to setup logging with a program using the jackrabbit-standalone-2.6.0.jar. This archive contains some slf4j-packages (org.slf4j, org.slf4j.helpers, org.slf4j.impl, org.slf4j.spi) but as far as I can see no logging framework. But when I add the slf4j-log4j12-1.7.2.jar I get the messages:

SLF4J: Found binding in [jar:file:/D:/Anwendungen/EclipsePlugins/Jackrabbit/jackrabbit-standalone-2.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/Anwendungen/EclipsePlugins/slf4j-1.7.2/slf4j-1.7.2/slf4j-log4j12-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]

Is there an opportunity to see which kind of implementer is used here?

I want to configure the logger. Right now it writes a big amount of DEBUG messages to a file called "jackrabit.log_IS_UNDEFINED" and I urgently need to suppress this. There are several hints to be found in the internet suggesting to setup the logger but I don't exactly understand what I need to do. The classes "DOMConfigurator" and "PropertyConfigurator" are not available within the package, but when adding for example "slf4j-log4j12-1.7.2.jar" I get the above described messages. So I can't initialize the logger within my program. It was said to add the configuration-XML to the classpath. I tried this (in Eclipse I added the folder conatining the XML to the BuildPath, then I created a jar-file from my XML-File and added this jar-file to the BuildPath) but it didn't make any difference.

I read the description "Default Initialization Procedure" in http://logging.apache.org/log4j/1.2/manual.html but have to state that I didn't understand it at all. What does it mean: 2. Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value "log4j.properties". Where do I have to specify the resource-string variable?

my log4j.xml-file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
         <appender name="Console" class="org.apache.log4j.ConsoleAppender">
             <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d  %-5p  [%c{1}] %m %n" />
            </layout>
        </appender>

        <root>
            <priority value="info" />
            <appender-ref ref="Console" />
        </root>
 </log4j:configuration>

Any idea to configure the logger either programmatically or be default initialization is very welcome.

Ulrich

1

1 Answers

0
votes

As of version 1.6.6, in case multiple bindings are found on the class path, SLF4J will output the name of the framework/implementation class it binds with. Just after the "SLF4J: Found binding" lines, there should be a line starting with:

"SLF4J: Actual binding is of type []"

Have you missed that line?

The contents of jackrabbit-standalone-2.6.0.jar indicate that its ships with logback as the logging framework. The jackrabbit-standalone-2.6.0.jar file also ships with a logback.xml configuration file.

Here is that logback.xml file:

<configuration>
  <appender name="jackrabbit" class="ch.qos.logback.core.FileAppender">
    <file>${jackrabbit.log}</file>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="jetty" class="ch.qos.logback.core.FileAppender">
    <file>${jetty.log}</file>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
    </encoder>
  </appender>

  <logger name="org.mortbay.log" level="${log.level}"
          additivity="false">
    <appender-ref ref="jetty"/>
  </logger>

  <root level="${log.level}">
    <appender-ref ref="jackrabbit"/>
  </root>
</configuration>

As in Unix shells, in logback.xml any string within ${} designates a variable.

Looking at the logback.xml file above, we can see that the variables ${jackrabbit.log}, ${jetty.log} and "${log.level} are referenced. These variables are set by the prepareServerLog() method in Main class of jackrabbit-standalone 2. The prepareServerLog() is invoked unless the "-i" or "--cli" option is given on the command line. Are you invoking jackrabbit with -i or --cli?

Anyway, it would be helpful to post here all messages printed by SLF4J as well the command you are using to launch jackrabbit-standalone.