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

Receiver - Can't handle model of type ReceiverModel with tag: receiver #706

Open
raymondsvendsen opened this issue Sep 29, 2023 · 6 comments

Comments

@raymondsvendsen
Copy link

raymondsvendsen commented Sep 29, 2023

Attempting Logback receiver feature I get this error:
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@76b10754 - Can't handle model of type class ch.qos.logback.classic.model.ReceiverModel with tag: receiver at line 11

My setup:

  • Arch Linux 6.5.5 kernel
  • Logback 1.3.11 (also tried other versions, including 1.4.x. 1.3 is prefered since I am stuck with java 8 in prod)
  • SLF4J 2.0.9 (also tried 2.0.7)
  • Java 8,11,17 all give same result
  • Also tried run application in a docker-container to rule out my environment ( maven:3.5-jdk-8)

To reproduce:
Structure:

./
├── pom.xml
└── src/
   └── main/
      ├── java/
      │  └── logbackreceiver/
      │     └── server/
      │        └── Main.java
      └── resources/
         └── logback.xml

Main.java:

package logbackreceiver.server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main {
  private static final Logger logger = LoggerFactory.getLogger(Main.class);
  static public void main(String[] args) {
    logger.info("Starting");
  }
}

logback.xml:
(I also tried the canonical style with same result)

<configuration debug="true">
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>[%date]-%msg%n</pattern>
        </encoder>
    </appender>
    <root level="DEBUG">
        <appender-ref ref="CONSOLE" />
    </root>
    <receiver class="ch.qos.logback.classic.net.server.ServerSocketReceiver">
        <port>3331</port>
    </receiver>
</configuration>

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>home.logbackreceiver</groupId>
  <artifactId>server</artifactId>
  <packaging>jar</packaging>
  <properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <version>1.0-SNAPSHOT</version>
  <name>logbackreceiverserver</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.3.11</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.3.11</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-access</artifactId>
      <version>1.3.11</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>2.0.9</version>
    </dependency>
  </dependencies>
</project>

To build and run:

mvn clean compile && sudo mvn exec:java -Dexec.mainClass="logbackreceiver.server.Main"

Following the guide here: https://logback.qos.ch/manual/receivers.html
I also cloned code from github (various versions here too) and run the example codes. Everything give me the same problem.
I tried various versions of Logback (3.x and 4.x). I tried Java 8,11,17
I would prefer to make Logback 3.x to work since I am stuck with Java 8 in prod.

I even tried run it in a Docker-container to rule out problems in my environment.

Complete log:

12:50:25,651 |-INFO in ch.qos.logback.classic.LoggerContext[default] - This is logback-classic version 1.3.11
12:50:25,652 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - No custom configurators were discovered as a service.
12:50:25,652 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - Trying to configure with ch.qos.logback.classic.joran.SerializedModelConfigurator
12:50:25,652 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - Constructed configurator of type class ch.qos.logback.classic.joran.SerializedModelConfigurator
12:50:25,664 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.scmo]
12:50:25,664 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.scmo]
12:50:25,664 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - ch.qos.logback.classic.joran.SerializedModelConfigurator.configure() call lasted 12 milliseconds. ExecutionStatus=INVOKE_NEXT_IF_ANY
12:50:25,664 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - Trying to configure with ch.qos.logback.classic.util.DefaultJoranConfigurator
12:50:25,665 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - Constructed configurator of type class ch.qos.logback.classic.util.DefaultJoranConfigurator
12:50:25,665 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:50:25,665 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/x/Projects/logbackreceiver/server/target/classes/logback.xml]
12:50:25,722 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [CONSOLE]
12:50:25,722 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:50:25,725 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:50:25,729 |-INFO in ch.qos.logback.classic.model.processor.RootLoggerModelHandler - Setting level of ROOT logger to DEBUG
12:50:25,729 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [CONSOLE] to Logger[ROOT]
12:50:25,730 |-ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@270251cf - Can't handle model of type class ch.qos.logback.classic.model.ReceiverModel  with tag: receiver at line
10
12:50:25,730 |-WARN in ch.qos.logback.core.model.processor.ImplicitModelHandler - Ignoring unknown property [port] in [ch.qos.logback.classic.LoggerContext]
12:50:25,730 |-ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@270251cf - Can't handle model of type class ch.qos.logback.classic.model.ReceiverModel  with tag: receiver at line
10
12:50:25,730 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@270251cf - End of configuration.
12:50:25,730 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@49fe6dec - Registering current configuration as safe fallback point
12:50:25,730 |-INFO in ch.qos.logback.classic.util.ContextInitializer@2e8123ad - ch.qos.logback.classic.util.DefaultJoranConfigurator.configure() call lasted 65 milliseconds. ExecutionStatus=DO_NOT_INVOKE_NEXT_IF_ANY
[2023-09-29 12:50:25,731]-Starting
@raymondsvendsen
Copy link
Author

I would be happy to know if this should work. Does no one use this feature?

@VolkerGoetz
Copy link

I have the very same error and opened a ticket in the old Jira tracker: https://jira.qos.ch/browse/LOGBACK-1743

PR #699 has a fix for this.

@raymondsvendsen
Copy link
Author

Thank you for the information.

@meyertee
Copy link

I ran into the same issue, thanks for the PR. Would be great to get an update on whether that's considered for merging into an upcoming release. Was there a reason not to support the receiver tag or just an oversight/bug?

@jhartelt
Copy link

Also encountered this issue. Until a new release is available, would I have to build the logback-classic.jar myself to fix this behaviour?

@PrometheusNox
Copy link

@ceki Any chances of addressing the issue in the near future? The bug basically makes the receiver functionality unusable but the PR posted above is a straightforward fix.

VolkerGoetz added a commit to VolkerGoetz/logback that referenced this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants