Thank you very much for the help! :)
On Jul 10, 2015 9:15 AM, "Konstantin Gribov" <[email protected]> wrote:
> Hi.
>
> If you use tika as usual library (no OSGi) you can configure any slf4j
> backend to log into a file. Before doing this you have to choose some of
> them. I recommend to use either Apache log4j 1.2 or logback-classic. This
> part of configuration can be found at wiki[1].
>
> Configuring backend to log into file is backend-dependent. In case of
> log4j you can create log4j.properties with something like this:
>
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p %t %c{2}:%L
> - %m%n
>
> log4j.appender.file=org.apache.log4j.RollingFileAppender
> log4j.appender.file.File=log/filecrawler.log
> log4j.appender.file.MaxFileSize=100MB
> log4j.appender.file.MaxBackupIndex=2
> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %t %c{2}:%L -
> %m%n
>
> log4j.rootLogger=WARN, file, stdout
>
> # for pdfbox
> log4j.logger.org.apache.pdfbox.pdmodel.font=FATAL
>
>
> For logback you can create logback.xml something like this:
>
> <?xml version="1.0"?>
> <configuration>
> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
> <encoder>
> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%15.15t{14}]
> %-40.40logger{39} : %m%n</pattern>
> </encoder>
> </appender>
>
> <appender name="FILE"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <file>log/filecrawler.log</file>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <fileNamePattern>log/filecrawler.log.%d{yyyy-MM-dd}</fileNamePattern>
> <maxHistory>30</maxHistory>
> </rollingPolicy>
> <encoder>
> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%15.15t{14}]
> %-40.40logger{39} : %m%n</pattern>
> </encoder>
> </appender>
>
> <root level="WARN">
> <appender-ref ref="CONSOLE" />
> <appender-ref ref="FILE" />
> </root>
>
> <logger name="org.apache.pdfbox.pdmodel.font" level="FATAL"/>
> </configuration>
>
>
> Either log4j.properties or logback.xml should be at root of classpath when
> application is executed (or path to them should be set via java system
> properties). In case of building with maven drop them to src/main/resources.
>
> [1]: https://wiki.apache.org/tika/Logging
>
> пт, 10 июля 2015 г. в 18:36, Gabriele Lanaro <[email protected]>:
>
>> Hi, I would like to know if it is possible to configure logging in tika,
>> for example I'd like to log to a file instead of standard output.
>> Redirection is not an option because I'm using tika as a library for
>> another application, and I'd like to log other parts of the application.
>>
>> Is there an easy way to configure tika logging globally?
>>
>> Thanks,
>> Gabriele
>>
> --
> Best regards,
> Konstantin Gribov
>