带有logback的Spring引导将一些系统日志打印到应用程序日志中



我之前在控制台中打印所有日志时遇到了问题。然后,在关注了一些帖子之后,我能够将日志打印到单独的应用程序日志中。

现在,在重新启动应用程序服务器(IBMWAS8.5(时,它正在将一些SystemOut日志打印到新创建的应用程序日志中。

渐变构建,排除了一些来自其他依赖的罐子

exclude(group: 'org.slf4j', module:'slf4j-nop')
all*.exclude group: "javax.servlet", module: "servlet-api"
all*.exclude group: "org.slf4j", module: "log4j-over-slf4j"
all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
all*.exclude group: "log4j", module: "log4j"

应用程序属性:-

logging.file=MySpringBoot-applicaiton.log

和logback.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>

MySpringBoot应用程序日志:

>     [server.startup : 1] o.s.integration.channel.DirectChannel    : Channel 'application.sendXXXXXXXXRequestChannel' has 1 subscriber(s).
>     [server.startup : 1] o.s.i.endpoint.EventDrivenConsumer       : started sendXXXXXXXOutboundGateway
>     [server.startup : 1] o.s.i.endpoint.EventDrivenConsumer       : Adding {ws:outbound-gateway(marshaling):sendXXXXXXXXOutboundGateway}
> as a subscriber to the 'sendXXXXXXXXXRequestChannel' channel
>     [server.startup : 1] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
>     [server.startup : 1] com.XXX.XXX.api.rest.ServletInitializer  : Started ServletInitializer in 47.992 seconds (JVM running for 142.685)
>     [server.startup : 1] com.ibm.ws.webcontainer.webapp           : SRVE0292I: Servlet Message -
> [MySpringBootEar-FUT.SNAPSHOT-0#MySpringBootWeb.war]:.Initializing
> Spring FrameworkServlet 'dispatcherServlet'
>     [server.startup : 1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
>     [server.startup : 1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 47
> ms
>     [server.startup : 1] c.i.w.w.servlet.ServletWrapper           : SRVE0242I: [MySpringBootEar-FUT.SNAPSHOT-0] [/mycustomurl]
> [dispatcherServlet]: Initialization successful.
>     [server.startup : 1] com.ibm.ws.webcontainer.webapp           : SRVE0292I: Servlet Message -
> [MySpringBootEar-FUT.SNAPSHOT-0#MySpringBootWar.war]:.Initializing
> Spring FrameworkServlet 'messageDispatcherServlet'
>     [server.startup : 1] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization started
>     [server.startup : 1] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization completed
> in 31 ms
>     [server.startup : 1] c.i.w.w.servlet.ServletWrapper           : SRVE0242I: [MySpringBootEar-FUT.SNAPSHOT-0] [/mycustomurl]
> [messageDispatcherServlet]: Initialization successful.
>     [server.startup : 1] com.ibm.ws.webcontainer.webapp           : SRVE0278E: Error while adding servlet mapping --> /*.
>     [server.startup : 1] com.ibm.ws.webcontainer                  : SRVE0250I: Web Module null has been bound to
> default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].

在最后两行日志中,它是来自服务器的消息,现在正在打印到应用程序日志中。

===================================================================更新:

2018-11-06 15:40:24.291  WARN 27132 --- [P=756984:O=0:CT] com.ibm.ws.runtime.WsServerImpl          : WSVR0001I: Server server1 open for e-business

上面的行现在正在打印到应用程序日志中,同时使用带有springboot的logback。没有logbackxml配置,只是将logging.file=添加到applicaiton.properties文件中。

上面的日志是IBM WebSphere日志。我的申请日志是怎么写的。

我遇到了类似的问题。您可以通过在logback.xml中添加以下内容,将与服务器启动相关的信息从应用程序日志重定向到webspherestdout.log:-

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.ibm.ws.runtime" level="warn"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>

相关内容

  • 没有找到相关文章

最新更新