Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error emitted when using a YAML configuration without additional dependency #1501

Open
designatevoid opened this issue Jun 2, 2023 · 5 comments
Labels
bug Incorrect, unexpected, or unintended behavior of existing code configuration Affects the configuration system in a general way
Milestone

Comments

@designatevoid
Copy link

Description

The software ignores YAML configuration silently if YAML configuration is used with the dependencies specified on the Maven, Ivy Gradle Artifacts page (log4j-api and log4j-core) but not with the Jackson Databind and YAML Data Format dependencies.

Configuration

Version: 2.20.0

Operating system: Windows 11 (build 22621.1702)

JDK: openjdk 19.0.2 2023-01-17

Logs

None, no warning about using default configurations or being unable to process a log4j2.yaml file found on the classpath.

Reproduction

  1. Create a YAML configuration file named log4j2.yaml on the classpath turning on debug messages.
  2. Create a unit test getting the logger and logging an error message and a debug message.
  3. Observe only the error message during runtime.

Thank you.

@rgoers
Copy link
Member

rgoers commented Jun 3, 2023

The call to getConfiguration returns null when dependencies are missing. We should probably log a warning as the method wouldn't have been called if the configuration file wasn't of a supported type.

@lukaszspyra
Copy link
Contributor

Hi @rgoers ,
I've done some checks with a/m setup, and looks like there are StatusLogger messages for missing dependencies (DEBUG) and using default config (WARN), however it requires setting system property log4j2.debug:

DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive

followed by:

WARN StatusLogger Found configuration file log4j2.yaml for inactive ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory
WARN StatusLogger 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

@ppkarwasz
Copy link
Contributor

@lukaszspyra,

Yes, you are right, the warnings are there, but they are disabled by default.

We should probably bump the level of both the StatusLogger (which is used when no configuration is active) and StatusConfiguration (which the default value of a configuration's status attribute) to WARN.

@lukaszspyra
Copy link
Contributor

Ok, I will have a look at it.

@lukaszspyra
Copy link
Contributor

Hi @ppkarwasz,
Could you please have a look on the draft PR? Especially point 3 regarding AbstractConfiguration, as it is used by many subclasses.
Still need to do some tests, unit would be difficult (StatusLogger singleton/no accessors in StatusConfiguration), so will try integration with dummy config files.

@ppkarwasz ppkarwasz added this to the 2.20.1 milestone Aug 29, 2023
@vy vy modified the milestones: 2.21.0, 2.x Oct 5, 2023
@jvz jvz added bug Incorrect, unexpected, or unintended behavior of existing code configuration Affects the configuration system in a general way labels Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect, unexpected, or unintended behavior of existing code configuration Affects the configuration system in a general way
Projects
None yet
Development

No branches or pull requests

6 participants