[
https://issues.apache.org/jira/browse/FELIX-6293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17161239#comment-17161239
]
Peter Kriens commented on FELIX-6293:
-------------------------------------
I dived into the code.
Logging happens in a hierarchy. If a logger is not enabled for logging, it is
reported to the parent. Each logger tries to create an internal OSGiLogger.
There are 3 different Scr loggers used throughout the code-base:
# `ScrLogger` – Logs the main SCR code. It uses the default bundle level of
the SCR bundle.
# `BundleLogger` – Logs bundle related messages. It uses the default bundle of
the bundle that holds the component. If the internal is not enabled, it will
log to the Scr Logger
# `ComponentLogger` – Logs the component related messages, it uses the
implementation class name + the bundle it resides in. If the internal logger is
disabled for a level, it logs the message on the Bundle Logger.
Each logger refers to an _internal logger_. This is either a Std Out Logger or
OSGiLogger.
!image-2020-07-20-15-22-24-373.png!
So I think we can achieve what we want if we change the ComponentLogger.
Currently, it gets a Logger from LoggerFactory using:
# The component's bundle
# the fully qualified implementation class name of the component
This behaviour is explicitly specified by OSGi and must, therefore, remain the
case as default.
I propose to introduce a `ds.log.bundle` configuration parameter of a boolean
type. Default is true and makes the code behave as it is today. When it is
explicitly set to {{false}} via framework properties or configuration, it will
_always_ use the Scr's bundle logger. However, it will use the following logger
names:
# BundleLogger – The logger name in the Scr bundle's logger will be the
_bundle symbolic name_
# ComponentLogger – The logger name in the Scr bundle's logger will be the
bundle symbolic name of its bundle, a dot and the implementation class name.
For example, if the ban is {{com.example.foo}} and the implementation is
{{com.example.foo.impl.Foo}} then the logger name is
{{com.example.foo.com.example.foo.impl.Foo}}
Therefore, to see (with {{ds.log.bundle}}=false):
# component – Enable <bsn>.<impl class name> on scr bundle
# bundle – Enable <bsn> on scr bundle (includes components, this cannot be
disabled since a component uses its parent bundle logger if not enabled for a
level. A bit bizarre)
> Apache Felix SCR Logging
> ------------------------
>
> Key: FELIX-6293
> URL: https://issues.apache.org/jira/browse/FELIX-6293
> Project: Felix
> Issue Type: Improvement
> Components: Declarative Services (SCR)
> Reporter: Peter Kriens
> Priority: Minor
> Attachments: image-2020-07-20-15-22-24-373.png
>
>
> Apache Felix SCR uses the component's logger name to find the level to log
> at. If the component happens to be on DEBUG, this then floods the log and
> makes it hard to debug the component.
> I'd like to add a System property that would provide the log name for SCR. If
> it is not set, the current behaviour is used.
> I can make this change if I get some feedback it is an acceptable idea.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)