Kolja Log4J Appender

The Kolja Log4J Appender can be used for any java processes using Log4J to write to the console. It handles a Log4J LoggingEvent , by converting it to a Kolja Line object, then using the formatters and highlighters used for tail.sh.

Log4J Value Kolja Field Type
e.timeStamp "date" java.util.Date
e.getMessage() "content" java.lang.String
e.getThrowableStrRep() "exception" java.lang.String
e.getLevel().toString() "priority" java.lang.String
e.getLoggerName "logger_id" java.lang.String
e.getThreadName "thread" java.lang.String
Mappings between LoggingEvent (Log4J) and Line (Kolja).

Using with the Maven Jetty Plugin

src/main/resources/log4j.xml

You can use your own log4j.xml, make sure it includes the following appender. The name is significant, in this case the kolja appender will load configuration from $KOLJA_HOME/conf/kolja.xml .

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

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
  <appender name="kolja" class="com.baulsupp.kolja.log4j.KoljaLogAppender">
  </appender>

  <root>
    <level value="info" />
    <appender-ref ref="kolja" />
  </root>
</log4j:configuration>

pom.xml [OPTIONAL]

You can customise the pom.xml to use a different log4j configuration. This is useful if you only want the Kolja Log4J Appender used in development.

<project>
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <configuration>
          ...
          <systemProperties>
            ...
            <systemProperty>
              <name>log4j.configuration</name>
              <value>
                file:./src/test/resources/log4j.xml
              </value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>