Document status | DRAFT |
---|---|
Document owner |
Introduction
OpenNLP uses System.out()
and System.err()
by default for logging. This is fine for instances in which OpenNLP's CLI tools are being used but may not be ideal when OpenNLP is used as a library. Previous work in this area includes
Jira | ||||||
---|---|---|---|---|---|---|
|
Current State
As discussed above, OpenNLP currently (as of 1.7.2) defaults to using System.out()
and System.err()
for logging messages and errors, respectively.
The Problem
When using OpenNLP as a library the output of logs to standard out and standard error is not ideal as these logs often need to be captured by the application for external storage and reporting (and also just to keep from cluttering up standard out).
Proposed Solution
The proposed solution is to create an OpenNLP Logger
interface that developers can implement to customize the logging. The user can provide their own implementation of this interface to control OpenNLP's logging. This interface will have to exist in a new project (perhaps opennlp-model
?) in order to avoid circular dependencies. (The opennlp-tools
project will have a dependency on this project. The user's project can either have an explicit dependency on opennlp-model
or a transitive dependency based on the project's requirements.)
...
Current | Proposed | ||||
---|---|---|---|---|---|
|
|
Summary
This proposal:
- Presents a way to let users of OpenNLP as a library to control logging.
- Requires:
- A new project that contains a Logger interface.
- Modifying current
System.out()
andSystem.err()
calls to reference the newLoggerConfiguration
class.
Future Work
A similar approach could be taken for functions that expect a PrintStream
object.
...