0

Forewarning: I am new to log4j logging and well logging in general and apologize for my ignorance.

When ever I run my program from a .jar I get a "jackrabbit.log_IS_UNDEFINED" file in the directory where my program was ran. This log file is Extremely large(300MB+) and filling up my drive. I can see that this file has DEBUG level logs in it from several different libraries that I am using. I wish to rid myself of this "jackrabbit.log_IS_UNDEFINED" file and log only ERROR level logs or above to my own file on another drive. eg. (/smb01/Aggregator.log). Any Help would be Greatly Appreciated.

Also when I run the jar from the command line I get a Log4j Error:

log4j:ERROR Root level cannot be inherited. Ignoring directive.

I do want/have to specify my own config file so we can log our own errors.
I have inherited this config file. Log4j.xml Config file:

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

<!-- Appender Types: 
    <ConsoleAppender> org.apache.log4j.ConsoleAppender</ConsoleAppender> 
    <FileAppender> org.apache.log4j.FileAppender</FileAppender>
    <JDBCAppender> org.apache.log4j.jdbc.JDBCAppender</JDBCAppender>
    <AsyncAppender> org.apache.log4j.AsyncAppender</AsyncAppender> 
    <JMSAppender> org.apache.log4j.net.JMSAppender</JMSAppender>
    <LF5Appender> org.apache.log4j.lf5.LF5Appender</LF5Appender>
    <NTEventLogAppender> org.apache.log4j.nt.NTEventLogAppender</NTEventLogAppender> 
    <NullAppender> org.apache.log4j.varia.NullAppender</NullAppender>
    <SMTPAppender> org.apache.log4j.net.SMTPAppender</SMTPAppender>
    <SocketAppender> org.apache.log4j.net.SocketAppender</SocketAppender> 
    <SocketHubAppender> org.apache.log4j.net.SocketHubAppender</SocketHubAppender> 
    <SyslogAppender> org.apache.log4j.net.SyslogAppender</SyslogAppender>
    <TelnetAppender> org.apache.log4j.net.TelnetAppender</TelnetAppender>
    <WriterAppender> org.apache.log4j.WriterAppender</WriterAppender> -->
<!-- (all|debug|info|warn|error|fatal|off|null) "null" -->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
    debug="false" threshold="fatal">

    <!-- Appenders -->
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p %c{1} - %m%n" />
        </layout>
    </appender>

    <appender name="FA" class="org.apache.log4j.FileAppender">
        <param name="File" value="sample.log" />
        <param name="Threshold" value="WARN" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" />
        </layout>
    </appender>

    <appender name="ROLL" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="/smb01/Aggregator.log" /> <!-- The active file to log to -->
        <param name="encoding" value="UTF-8"/>
        <param name="append" value="true" />
        <param name="Threshold" value="WARN" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ISO8601}|%5p|%t| %c{1} | %m%n"/>
        </layout>
    </appender>

    <appender name="CustomerReport" class="org.apache.log4j.FileAppender">
        <param name="file" value="CustomerReport.csv" />
        <param name="append" value="FALSE" />
        <param name="Threshold" value="INFO" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%m%n" />
        </layout>
    </appender>

    <appender name="rootAppender" class="org.apache.log4j.varia.NullAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%-5p] %c{1} - %m%n" />
        </layout>
    </appender>


    <!-- Loggers -->
    <!-- Standard Levels: DEBUG < INFO < WARN < ERROR < FATAL -->
    <logger name="com.group">
        <level value="info" />
        <appender-ref ref="console" />
        <appender-ref ref="ROLL" />
    </logger>

    <logger name="com.group.main">
        <level value="info" />
        <appender-ref ref="console" />
        <appender-ref ref="ROLL" />
    </logger>

    <logger name="com.group.customerLogger">
        <level value="info"/>
        <appender-ref ref="CustomerReport"/>
    </logger>

    <!-- Root Logger -->
    <root>
        <level value="FATAL"/>
        <appender-ref ref="rootAppender"/>
    </root>

</log4j:configuration>

Since this is for my work I cant share all of my code but here are the key bits:

import org.apache.log4j.xml.DOMConfigurator;
import org.apache.log4j.*;
import org.apache.log4j.Logger;

public class Main {
  public static Logger logger = Logger.getLogger("com.group.main");

  public static void main(String[] args) {

    // setup the log4j system so we can log stuff.
    org.apache.log4j.extras.DOMConfigurator.configure(args[1]);
    .
    .
    logger.debug("debug message!");
    .
    .
    .
  }

The files Aggregator.log and CustomerReport.csv do Show up where they are supposed to but nothing is logged/written to them. I have been able to look at the "jackrabbit.log_IS_UNDEFINED" file and it has all of my logging in it.

Libraries that deal with log4j that i'm using(listed via build path order):

  • log4j-1.2.17.jar
  • apache-log4j-extras-1.1.jar
  • jackrabbit-standalone-2.2.10.jar

More Info

I found another xml file with what appears to be my culprit: logback.xml

<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>

Can I (edit/remove/workaround) this file?

Archangel33
  • 496
  • 8
  • 22

2 Answers2

1

I ended up not using jackrabbit-standalone-2.2.10.jar which eliminated the error altogether. Instead I imported only specific classes from various other libraries included in CQ 5.4. I Still have the same setup as shown above except for the jackrabbit-standalone-2.2.10.jar. @TedTrippin, Thank you for your time and consideration.

Archangel33
  • 496
  • 8
  • 22
0

Do you mean to be passing in the log4j config file? Log4j should pick up the config itself as long as the log4j.xml is in the classpath. Make sure it is and remove this:

org.apache.log4j.extras.DOMConfigurator.configure(args[1]);

then try again.

It doesn't look like your config, the one you have pasted, is to blame as there is no mention of jackrabbit in there. I wonder if another config is being picked up from elsewhere?

TedTrippin
  • 3,525
  • 5
  • 28
  • 46
  • I thought I did need to pass in the log4j config, but if I don't need to then I try that. I will look for another one somewhere but I don't see it anywhere obvious. could it be in another .jar? – Archangel33 Jun 19 '12 at 13:31
  • In another jar - yes, that's what I was thinking. Out of interest, do you see the files in your config created (/smb01/Aggregator.log, CustomerReport.csv, sample.log)? If/when you see these files you know you're config is being used. Also, if you DO want to explicitly specify your config file I use org.apache.log4j.PropertyConfigurator. I like to use configureAndWatch() so I can quickly turn debug off/on. – TedTrippin Jun 19 '12 at 14:50
  • Yes both the `CustomerReport.csv` and the `/smb01/Aggregator.log` are where they are supposed to be but sample.log is not created(I don't use the appender FA it was my original file appender test). I DO want to specify my own config for my own output. You think I should use a property file instead of an xml config? I will try this as well. Is one better than the other? I thought I read that xml was to be used with log4j-1.2.x. – Archangel33 Jun 19 '12 at 15:54
  • one more thing the files are empty nothing is logged/written to them though. – Archangel33 Jun 19 '12 at 16:00
  • I found a logback.log file with what seems to be the issue. Is there a way to remove this file and not break jackrabbit? can I use it and my own by adding appenders? If I can I'll add this as a feature on the [appache wiki](http://wiki.apache.org/logging-log4j/Log4jXmlFormat). – Archangel33 Jun 19 '12 at 20:17
  • Good point, need DOMConfigurator for xml config. My bad! I don't advocate one or the other. As for empty logs, 2 things 1) Setting log level to info will only log info and above, not debug. 2) Logger name corresponds to package so eg. class "com.group.TestLogging" would use logger "com.group". As your main class has no package it will use the root logger. As your root logger is set to fatal it will not log debug messages, only fatal. – TedTrippin Jun 20 '12 at 09:07
  • Finally, I don't know what to suggest for your jackrabbit logging problem, I've never seen jackrabbit create its own logs like this. In my experience log4j picks up the default config or the config you explicitly pass it. Is it possible that this logback.log is being created elsewhere in your code? – TedTrippin Jun 20 '12 at 09:07
  • The logback.log does not come from my code but it may come from a jar that I am using. This is the only file I write out. It seems as though no one on the internet has any knowledge of this "jackrabbit.log_IS_UNDEFINED" file. I fixed the empty logs issue thanks @TedTrippin. – Archangel33 Jun 21 '12 at 06:01