Skip to content

Commit

Permalink
add warning about the deprecation of SerializedModelConfigurator if a…
Browse files Browse the repository at this point in the history
…ctivated

Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Feb 11, 2025
1 parent 5610c96 commit f5b3bc5
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public ExecutionStatus configure(LoggerContext loggerContext) {

URL url = performMultiStepModelFileSearch(true);
if (url != null) {
addWarn("Replaced by logback-tyler, SerializedModelConfigurator has been deprecated and will be removed on 2025-07-01.");
configureByResource(url);
return ExecutionStatus.DO_NOT_INVOKE_NEXT_IF_ANY;
} else {
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2025, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/

package ch.qos.logback.classic.issue.github450;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggerContextListener;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.spi.LifeCycle;
import org.slf4j.MDC;

public class Issues450LoggerContextListener extends ContextAwareBase implements LoggerContextListener, LifeCycle {

boolean started = false;

@Override
public void start() {
MDC.put("issues450", "12");
started = true;
}

@Override
public void stop() {
started = false;
}

@Override
public boolean isStarted() {
return started;
}

@Override
public boolean isResetResistant() {
return false;
}

@Override
public void onStart(LoggerContext context) {

}

@Override
public void onReset(LoggerContext context) {

}

@Override
public void onStop(LoggerContext context) {

}

@Override
public void onLevelChange(Logger logger, Level level) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2025, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/

package ch.qos.logback.classic.issue.github450;

import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.ClassicTestConstants;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.read.ListAppender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

public class Main {

public static void main(String[] args) {
System.setProperty(ClassicConstants.CONFIG_FILE_PROPERTY, "logback-classic/"+ClassicTestConstants.INPUT_PREFIX + "issue/gh_issues_450.xml");
System.setProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY, "stdout");
Logger logger = LoggerFactory.getLogger(Main.class);
logger.info("toto");
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);

ListAppender listAppender = (ListAppender) root.getAppender("LIST");

LoggingEvent le0 = (LoggingEvent) listAppender.list.get(0);

String val = le0.getMDCPropertyMap().get("issues450");
if(val == null) {
throw new RuntimeException("issues450 missing property: issues450");
}
}
}

0 comments on commit f5b3bc5

Please sign in to comment.