You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by Apache Wiki <wi...@apache.org> on 2015/01/20 18:32:59 UTC

[Tika Wiki] Update of "Logging" by KonstantinGribov

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tika Wiki" for change notification.

The "Logging" page has been changed by KonstantinGribov:
https://wiki.apache.org/tika/Logging

Comment:
Add page about logging in Tika

New page:
= Logging =

Apache Tika include a lot of Apache and thirdparty libraries that have different approach to logging.


== tika-core ==

{{{tika-core}}} should have no external dependencies to be as lightweight as it can, so we have to use
{{{java.util.logging}}} there.

== tika-parsers ==

{{{tika-parsers}}} depends on many Apache and thirdparty libraries. Currently, parsers in it usually use
logging approach from underlying library, e. g. parsers in {{{o.a.tika.parsers.microsoft}}} which use Apache POI
depends on Apache Commons Logging and Apache Log4j 1.2.

Currently {{{tika-parsers}}} depends on these logging solutions:

 * [[http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html|java.util.logging]]
 * [[http://commons.apache.org/proper/commons-logging/|Apache Commons Logging]]
 * [[http://logging.apache.org/log4j/1.2/|Apache Log4j 1.2]]
 * [[http://slf4j.org/|slf4j]]

It makes logging in application (which depends on {{{tika-parsers}}}) a bit harder.

One way to have consistent logging (i. e. one logging configuration point) is to choose one backend and use
slf4j as integration api.

In this case exclude all other logger deps except choosen logging backend and add all appropriate bridges.

If you use Apache Maven dependency section in {{{pom.xml}}} will contain something like this:

{{{#!xml
  <properties>
    <tika.version>1.7</tika.version>
    <slf4j.version>1.7.7</slf4j.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-parsers</artifactId>
      <version>${tika.version}</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
  </dependencies>
}}}

If you want to use native {{{slf4j}}} implementation, you can use [[http://logback.qos.ch/|logback]]:

{{{#!xml
  <properties>
    <tika.version>1.7</tika.version>
    <slf4j.version>1.7.7</slf4j.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-parsers</artifactId>
      <version>${tika.version}</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.1.2</version>
    </dependency>
  </dependencies>
}}}