uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joern Kottmann <kottm...@gmail.com>
Subject Re: uima v3 logging
Date Sun, 12 Feb 2017 10:36:35 GMT
On Sun, Feb 12, 2017 at 3:57 AM, Marshall Schor <msa@schor.com> wrote:

> On 2/11/2017 6:52 PM, Joern Kottmann wrote:
> > Hmm, isn't get getUimaLogger the same as getContext().getLogger() before?
> Yes.
> > In my opinion our goal should be to remove that at some point. UIMA is
> > easier to use for new users when there is not so much confusion with old
> > legacy things around for backward compatibility.
> >
> > For your first point about getLogger(), wouldn't this be solved by the
> MDC?
> > The annotator name is always present in the context.
> I think there are two ways the annotator name is used in logging.  One is
> to
> provide information (this is what the MDC does, I believe), and the other
> is to
> provide filtering - in that each "named" logger can have a
> configured-at-deploy-time-level-spec.  I don't think there is a simple
> direct
> way to say I want to run a particular annotator at "trace" level, for
> example,
> without that annotator name being the name of a logger that you get with
> getUimaLogger().
>
> But, maybe I don't fully understand this - logging details are fairly new
> to me...
>
> If this is true, then you still need to have named loggers in order to
> filter.
>


Lets says we write the annotator name into the mdc. In that case log4j2 can
use the ThreadContextMapFilter to filter log messages based on properties
in the mdc.

Have a look here:
https://logging.apache.org/log4j/2.x/manual/filters.html



> >
> > The user will have a hard time making use of that in more serious
> > applications. It would be awkward to pass the logger reference to other
> > classes and dependencies might just log directly to our logger backend.
> I agree.  There's a kind of work around for the use case where an Annotator
> (which would have a named logger) calls other code, perhaps deeply nested,
> and
> somewhere deep down, that code wants to log something.  If it wants to log
> using
> the Uima Logger, it could by using the call
> UimaContextHolder.getContext().getLogger()
>
> SLF4j's way of getting loggers is:
> Logger.getLogger(String name) or
> Logger.getLogger(Class clazz)
>
> They don't have a 0-argument constructor.
>
>

Maybe I am wrong here but I really don't think it is important that
annotator name is the same as the logger name, because the annotator name
should always be in the mdc.

This should work out of the box until the user starts his own threads
(because then the mdc will be empty).

Jörn

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message