Red5-1.0-RC1整合到tomcat,logback报错问题

本文介绍了解决Logback配置中SocketAppender连接拒绝的问题,通过删除logback.xml配置文件中的<consolePlugin/>标签来避免启动时出现警告信息。

08:14:10,515 |-INFO in ch.qos.logback.classic.net.SocketAppender[null] - Starting a new connector thread.
08:14:10,515 |-WARN in ch.qos.logback.classic.net.SocketAppender[null] - Could not connect to remote logback server at [localhost]. We will try again later. java.net.ConnectException: Connection refused: connect
 at java.net.ConnectException: Connection refused: connect
 at  at java.net.PlainSocketImpl.socketConnect(Native Method)
 at  at java.net.PlainSocketImpl.doConnect(Unknown Source)
 at  at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
 at  at java.net.PlainSocketImpl.connect(Unknown Source)
 at  at java.net.SocksSocketImpl.connect(Unknown Source)
 at  at java.net.Socket.connect(Unknown Source)
 at  at java.net.Socket.connect(Unknown Source)
 at  at java.net.Socket.<init>(Unknown Source)
 at  at java.net.Socket.<init>(Unknown Source)
 at  at ch.qos.logback.core.net.SocketAppenderBase.connect(SocketAppenderBase.java:130)
 at  at ch.qos.logback.core.net.SocketAppenderBase.start(SocketAppenderBase.java:81)
 at  at ch.qos.logback.classic.joran.action.ConsolePluginAction.begin(ConsolePluginAction.java:53)
 at  at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:273)
 at  at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145)
 at  at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:127)
 at  at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:40)
 at  at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:332)
 at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:126)
 at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:93)
 at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:52)
 at  at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77)
 at  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
 at  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
 at  at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
 at  at java.lang.Class.forName0(Native Method)
 at  at java.lang.Class.forName(Unknown Source)
 at  at org.red5.logging.Red5LoggerFactory.getLogger(Red5LoggerFactory.java:120)
 at  at org.red5.logging.Red5LoggerFactory.getLogger(Red5LoggerFactory.java:108)
 at  at org.red5.server.war.WarLoaderServlet.<clinit>(WarLoaderServlet.java:65)
 at  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at  at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at  at java.lang.Class.newInstance0(Unknown Source)
 at  at java.lang.Class.newInstance(Unknown Source)
 at  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4150)
 at  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
 at  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
 at  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
 at  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
 at  at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
 at  at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
 at  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
 at  at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
 at  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
 at  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
 at  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
 at  at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
 at  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
 at  at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
 at  at org.apache.catalina.core.StandardService.start(StandardService.java:525)
 at  at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
 at  at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
 at  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at  at java.lang.reflect.Method.invoke(Unknown Source)
 at  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

 

这种错误虽然说无关紧要,但是看着不舒服,解决办法把logback.xml日志配置文件里的<consolePlugin/>删掉就行了

为了在 Maven 工程中使用 `opentelemetry-logback-mdc` 模块,需要在 `pom.xml` 文件中添加对应的依赖声明。针对版本 `1.0` 的 `opentelemetry-logback-mdc`,其 Maven 依赖配置如下: ```xml <dependency> <groupId>io.opentelemetry</groupId> <artifactId>opentelemetry-logback-mdc</artifactId> <version>1.0.0</version> </dependency> ``` 此依赖会引入 OpenTelemetry 提供的 Logback MDC 集成模块,用于在日志中自动注入分布式追踪上下文信息(如 Trace ID 和 Span ID)[^4]。通过 Logback 的 MDC 支持,可以在日志输出模板中使用 `%X{trace_id}` 和 `%X{span_id}` 等格式化参数,将追踪信息嵌入日志条目中,便于日志分析与调试[^2]。 OpenTelemetry 与 Logback 的集成依赖于 MDC(Mapped Diagnostic Context),这是一种线程绑定的诊断上下文机制,允许在日志中附加与当前请求相关的上下文信息。在分布式系统中,这种机制尤其重要,因为它有助于将来自多个服务的日志条目关联到同一个请求或事务中[^3]。 ### 配置示例 在 `logback-spring.xml` 或 `logback.xml` 中,可以配置日志输出格式以包含 OpenTelemetry 的追踪信息: ```xml <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - [%X{trace_id}] [%X{span_id}] - %msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </configuration> ``` 上述配置会在每条日志输出中显示当前请求的 Trace ID 和 Span ID,从而方便地将日志条目与分布式追踪关联起来[^2]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值