apache / apache/logging-log4j2

Uniform handling of location and URIs

Open
#2,537 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

Many Log4j components use URI-sh configuration attributes:

- configuration factories allow a [`ConfigurationSource`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/config/ConfigurationSource) to be specified as URI, URL or file name,
- the [`MutableThreadContextMapFilter`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilter) accepts an URI or file name to retrieve its configuration,
- JSON Template Layout accepts an URI to retrieve its configuration.

Each of these configuration attributes is handled in a different way. For example:

- JTL only handles `file:` and `classpath:` URIs,
- the way URIs without a schema are interpreted differs.

We should introduce an abstraction similar to [`ResourceLoader`](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/ResourceLoader.html) that:

- supports at least the `classpath`, `file`, `http` and `https` protocols,
- is extensible to new protocol handlers,
- specifies how a relative URI without a protocol needs to be interpreted. This mechanism should be extensible: e.g. a standard implementation could interpret it as `classpath` or `file` resources. A `log4j-web` specific implementation could interpret it as `war`, `classpath` or `file` resource,
- has a coherent way to handle errors: file names and Java URLs don't always follow the URI syntax.

**Remark**: other Log4j components might also profit from this abstraction. For example the `File` appender could be easily adapted to use network filesystem URIs or at least it should be able to use NIO file systems.

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.