logback在不设置spring配置的情况下记录消息两次

o2g1uqev  于 2021-07-15  发布在  Java
关注(0)|答案(0)|浏览(240)

我目前还不熟悉spring框架,所以如果我犯了一个愚蠢的错误,我很抱歉。我最近合并了一个带有自定义日志格式的普通项目和一个带有 spring-websocket . 我正在尝试配置 logback 格式与原始格式匹配,但我遇到了两次记录行的问题。在尝试排除故障后,什么都没用。所以我试着删除配置文件 (logback-spring.xml) ,它再次记录了两次消息。我试图看看是否有什么关于这些双重消息发生没有设置配置,但没有任何效果。然而,我注意到的一点是,在我最初的项目开始打印信息之前,日志记录工作正常,根本没有双重日志记录。但在它开始打印信息之后,就出现了双间距。
下面是日志的样子:

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.3)

2021-03-25 11:25:41.198  INFO 60144 --- [           main] com.projectjhs.forum.Main                : Starting Main using Java 14.0.2 on #### with PID 60144 (####\target\classes started by ckromero in ####)
2021-03-25 11:25:41.201  INFO 60144 --- [           main] com.projectjhs.forum.Main                : No active profile set, falling back to default profiles: default
2021-03-25 11:25:42.008  INFO 60144 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-03-25 11:25:42.018  INFO 60144 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-03-25 11:25:42.018  INFO 60144 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.43]
2021-03-25 11:25:42.126  INFO 60144 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-03-25 11:25:42.126  INFO 60144 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 887 ms
2021-03-25 11:25:42.211  INFO 60144 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'clientInboundChannelExecutor'
2021-03-25 11:25:42.214  INFO 60144 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'clientOutboundChannelExecutor'
2021-03-25 11:25:42.225  INFO 60144 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'messageBrokerTaskScheduler'
2021-03-25 11:25:42.261  INFO 60144 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'brokerChannelExecutor'
2021-03-25 11:25:42.449  INFO 60144 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2021-03-25 11:25:42.805  INFO 60144 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-03-25 11:25:42.807  INFO 60144 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : Starting...
2021-03-25 11:25:42.808  INFO 60144 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry@f0a66bd]]
2021-03-25 11:25:42.808  INFO 60144 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : Started.
2021-03-25 11:25:42.816  INFO 60144 --- [           main] com.projectjhs.forum.Main                : Started Main in 1.937 seconds (JVM running for 2.781)
[example2]
[example]
[03/25 11:25:43:0200] [Main] INFO: Starting server
[03/25 11:25:43:0206] [Main] INFO: Starting threads
[03/25 11:25:43:0250] [Main] INFO: Starting CommandLineReaderThread
[03/25 11:25:43:0250] [Main] INFO: CommandLineReaderThread started
[03/25 11:25:43:0250] [Main] INFO: Starting WebServerThread
[03/25 11:25:43:0251] [Main] INFO: WebServerThread started
[03/25 11:25:43:0251] [Web Server] INFO: Starting Http server
[03/25 11:25:43:0251] [Main] INFO: Starting APIThread
[03/25 11:25:43:0251] [Main] INFO: APIThread started
[03/25 11:25:43:0252] [Main] INFO: Starting RequestThread
[03/25 11:25:43:0252] [Main] INFO: RequestThread started
[03/25 11:25:43:0253] [Main] INFO: Starting DiscordThread
[03/25 11:25:43:0253] [Main] INFO: DiscordThread started
// As you can see, this is where the double logging begins
2021-03-25 11:25:43.273  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Automatically disabled CacheFlags due to missing intents
2021-03-25 11:25:43.273  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Automatically disabled CacheFlags due to missing intents
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Disabled CacheFlag.VOICE_STATE (missing GatewayIntent.GUILD_VOICE_STATES)
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Disabled CacheFlag.VOICE_STATE (missing GatewayIntent.GUILD_VOICE_STATES)
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Disabled CacheFlag.EMOTE (missing GatewayIntent.GUILD_EMOJIS)
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Disabled CacheFlag.EMOTE (missing GatewayIntent.GUILD_EMOJIS)
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : You can manually disable these flags to remove this warning by using disableCache(CacheFlag.VOICE_STATE, CacheFlag.EMOTE) on your JDABuilder
2021-03-25 11:25:43.274  WARN 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : You can manually disable these flags to remove this warning by using disableCache(CacheFlag.VOICE_STATE, CacheFlag.EMOTE) on your JDABuilder
[03/25 11:25:43:0280] [Web Server] INFO: Http server started
2021-03-25 11:25:43.948  INFO 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Login Successful!
2021-03-25 11:25:43.948  INFO 60144 --- [       Thread-6] net.dv8tion.jda.api.JDA                  : Login Successful!
2021-03-25 11:25:44.137  INFO 60144 --- [nWS-WriteThread] n.d.j.internal.requests.WebSocketClient  : Connected to WebSocket
2021-03-25 11:25:44.137  INFO 60144 --- [nWS-WriteThread] n.d.j.internal.requests.WebSocketClient  : Connected to WebSocket
2021-03-25 11:25:44.415  INFO 60144 --- [inWS-ReadThread] net.dv8tion.jda.api.JDA                  : Finished Loading!
2021-03-25 11:25:44.415  INFO 60144 --- [inWS-ReadThread] net.dv8tion.jda.api.JDA                  : Finished Loading!
2021-03-25 11:26:42.287  INFO 60144 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2021-03-25 11:26:42.287  INFO 60144 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2021-03-25 11:30:41.373  INFO 60144 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-03-25 11:30:41.373  INFO 60144 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-03-25 11:30:41.373  INFO 60144 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-03-25 11:30:41.373  INFO 60144 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-03-25 11:30:41.375  INFO 60144 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2021-03-25 11:30:41.375  INFO 60144 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2021-03-25 11:56:42.300  INFO 60144 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 2, active threads = 1, queued tasks = 0, completed tasks = 1]
2021-03-25 11:56:42.300  INFO 60144 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 2, active threads = 1, queued tasks = 0, completed tasks = 1]
2021-03-25 12:26:42.304  INFO 60144 --- [MessageBroker-2] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 3, active threads = 1, queued tasks = 0, completed tasks = 2]
2021-03-25 12:26:42.304  INFO 60144 --- [MessageBroker-2] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 3, active threads = 1, queued tasks = 0, completed tasks = 2]

使用Spring 2.4.3 ,和java 14 谢谢您。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题