Bump version.io.micronaut from 4.1.0 to 4.1.1 (#197)
* Bump version.io.micronaut from 4.1.0 to 4.1.1 Bumps `version.io.micronaut` from 4.1.0 to 4.1.1. Updates `io.micronaut.platform:micronaut-platform` from 4.1.0 to 4.1.1 - [Release notes](https://github.com/micronaut-projects/micronaut-platform/releases) - [Commits](https://github.com/micronaut-projects/micronaut-platform/compare/v4.1.0...v4.1.1) Updates `io.micronaut:micronaut-inject-java` from 4.1.0 to 4.1.1 - [Release notes](https://github.com/micronaut-projects/micronaut-core/releases) - [Changelog](https://github.com/micronaut-projects/micronaut-core/blob/4.1.x/RELEASE.adoc) - [Commits](https://github.com/micronaut-projects/micronaut-core/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: io.micronaut.platform:micronaut-platform dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.micronaut:micronaut-inject-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix build --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Stephan Schnabel <stephan.schnabel@posteo.de>
This commit is contained in:
parent
0357b67026
commit
b3d0d49cc0
3 changed files with 35 additions and 8 deletions
5
pom.xml
5
pom.xml
|
@ -64,14 +64,13 @@
|
||||||
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<maven.compiler.implicit>class</maven.compiler.implicit>
|
||||||
<invoker.parallelThreads>1C</invoker.parallelThreads>
|
|
||||||
|
|
||||||
<!-- ===================================================================== -->
|
<!-- ===================================================================== -->
|
||||||
<!-- ============================= Versions ============================== -->
|
<!-- ============================= Versions ============================== -->
|
||||||
<!-- ===================================================================== -->
|
<!-- ===================================================================== -->
|
||||||
|
|
||||||
<version.io.micronaut>4.1.0</version.io.micronaut>
|
<version.io.micronaut>4.1.1</version.io.micronaut>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.kokuwa.micronaut.logging.mdc;
|
package io.kokuwa.micronaut.logging.mdc;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -13,33 +14,58 @@ import io.micronaut.context.annotation.Requires;
|
||||||
import io.micronaut.context.env.Environment;
|
import io.micronaut.context.env.Environment;
|
||||||
import io.micronaut.core.type.Argument;
|
import io.micronaut.core.type.Argument;
|
||||||
import io.micronaut.core.util.StringUtils;
|
import io.micronaut.core.util.StringUtils;
|
||||||
|
import io.micronaut.logging.LogLevel;
|
||||||
|
import io.micronaut.logging.LoggingSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure MDC filter.
|
* Configure MDC filter.
|
||||||
*
|
*
|
||||||
* @author Stephan Schnabel
|
* @author Stephan Schnabel
|
||||||
*/
|
*/
|
||||||
|
@BootstrapContextCompatible
|
||||||
@Requires(beans = LogbackUtil.class)
|
@Requires(beans = LogbackUtil.class)
|
||||||
@Requires(property = MDCTurboFilterConfigurer.PREFIX)
|
@Requires(property = MDCTurboFilterConfigurer.PREFIX)
|
||||||
@Requires(property = MDCTurboFilterConfigurer.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
|
@Requires(property = MDCTurboFilterConfigurer.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
|
||||||
@BootstrapContextCompatible
|
|
||||||
@Context
|
@Context
|
||||||
public class MDCTurboFilterConfigurer {
|
public class MDCTurboFilterConfigurer implements LoggingSystem {
|
||||||
|
|
||||||
public static final String PREFIX = "logger.mdc";
|
public static final String PREFIX = "logger.mdc";
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(MDCTurboFilterConfigurer.class);
|
private static final Logger log = LoggerFactory.getLogger(MDCTurboFilterConfigurer.class);
|
||||||
|
|
||||||
private final LogbackUtil logback;
|
private final LogbackUtil logback;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
|
private Collection<String> mdcs = Set.of();
|
||||||
|
private boolean initialized;
|
||||||
|
|
||||||
public MDCTurboFilterConfigurer(LogbackUtil logback, Environment environment) {
|
public MDCTurboFilterConfigurer(LogbackUtil logback, Environment environment) {
|
||||||
this.logback = logback;
|
this.logback = logback;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
configure();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure() {
|
@Override
|
||||||
for (var name : environment.getPropertyEntries(PREFIX)) {
|
public void refresh() {
|
||||||
|
|
||||||
|
mdcs = environment.getPropertyEntries(PREFIX);
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
|
if (environment.getProperties("logger.levels").isEmpty()) {
|
||||||
|
log.warn("MDCs are configured, but no levels are set. MDC may not work.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogLevel(String name, LogLevel level) {
|
||||||
|
if (!initialized) {
|
||||||
|
configure();
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configure() {
|
||||||
|
for (var name : mdcs) {
|
||||||
|
|
||||||
var prefix = PREFIX + "." + name + ".";
|
var prefix = PREFIX + "." + name + ".";
|
||||||
var key = environment.getProperty(prefix + "key", String.class, name);
|
var key = environment.getProperty(prefix + "key", String.class, name);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
logger:
|
logger:
|
||||||
|
levels:
|
||||||
|
io.micronaut.logging.PropertiesLoggingLevelsConfigurer: "OFF"
|
||||||
mdc:
|
mdc:
|
||||||
key1:
|
key1:
|
||||||
key: key
|
key: key
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue