apache / apache/logging-log4j2

Environment Service Missing

Open
#1,741 8 comments 0 reactions 0 assignees View on GitHub
bug osgi runtime
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

## Description

We created an application based on Eclipse 2023-06 (4.28).
The very first time we start the application the log4j2 logic is initialized correctly and we can see log messages.
But after closing the application the following start commands will not initialize log4j2 correctly and fail.
No exyception is shown and no log messages are created anymore.

From second time on, log4j is using a default implementation for all logger variables.

it seems that the services which provide Environment variable information are not registeed correctly when initializing/calling
org.apache.logging.log4j.util.PropertiesUtil$Environment
```
sources.add(propertySource);
// We don't log anything on the status logger.
ServiceLoaderUtil.loadServices(PropertySource.class, MethodHandles.lookup(), false, false).forEach(sources::add);
```

While initializing log4j2, the System properties are not available and thats why our *.xml is not fetched
_-Dlog4j2.debug=true
-DLog4jContextSelector=org.apache.logging.log4j.core.selector.BasicContextSelector
-Dlog4j2.configurationFile=file:log4j2.xml_

from bundle.info
org.apache.logging.log4j.1.2-api,2.20.0,plugins/org.apache.logging.log4j.1.2-api_2.20.0.jar,4,false
org.apache.logging.log4j.api,2.20.0,plugins/org.apache.logging.log4j.api_2.20.0.jar,3,true
org.apache.logging.log4j.core,2.20.0,plugins/org.apache.logging.log4j.core_2.20.0.jar,3,true
org.apache.logging.log4j.jcl,2.20.0,plugins/org.apache.logging.log4j.jcl_2.20.0.jar,4,false
org.apache.logging.log4j.slf4j-impl,2.20.0,plugins/org.apache.logging.log4j.slf4j-impl_2.20.0.jar,4,false

## Configuration

**Version:** [Log4j version]
org.apache.logging.log4j.1.2-api_2.20.0
org.apache.logging.log4j.api_2.20.0
org.apache.logging.log4j.core_2.20.0
org.apache.logging.log4j.jcl_2.20.0
org.apache.logging.log4j.slf4j-impl_2.20.0

**Operating system:** [OS and version]
org.osgi.framework.os.name = Windows10
osgi.ws = win32
sun.arch.data.model = 64

**JDK:** [JDK distribution and version]
Eclipse Adoptium Temurin-17.0.8+7

## Logs

Can not provide any logs, because they ar emissing.
We assume a plugin loading order issue or a service registration problem.

WARN StatusConsoleListener No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
WARN StatusConsoleListener No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

## Reproduction

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.