新人求教springboot在Linux下通过jar包启动后不断弹出大量日志怎么解决?

扣孜君 2018-10-30 05:47:48
通过Springboot写了一个http服务,日志级别设置的INFO,在windows下启动jar一切正常,但把jar包发布到Linux下启动则不断打印大量的日志。

Linux下启动部分日志:

2018-10-30 14:37:17.223 [main] DEBUG o.s.b.logging.ClasspathLoggingApplicationListener - Application started with classpath: [jar:f..........
2018-10-30 14:37:17.229 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [servletConfigInitParams]
2018-10-30 14:37:17.230 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [servletContextInitParams]
2018-10-30 14:37:17.230 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [systemProperties]
2018-10-30 14:37:17.230 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [systemEnvironment]
2018-10-30 14:37:17.230 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [random]
2018-10-30 14:37:17.231 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'context.listener.classes' in [applicationConfigurationProperties]
2018-10-30 14:37:17.231 [main] DEBUG o.s.core.env.PropertySourcesPropertyResolver - Could not find key 'context.listener.classes' in any property source
2018-10-30 14:37:17.236 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [servletConfigInitParams]
2018-10-30 14:37:17.237 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [servletContextInitParams]
2018-10-30 14:37:17.237 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [systemProperties]
2018-10-30 14:37:17.237 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [systemEnvironment]
2018-10-30 14:37:17.238 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [random]
2018-10-30 14:37:17.238 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.image.location' in [applicationConfigurationProperties]
2018-10-30 14:37:17.238 [main] DEBUG o.s.core.env.PropertySourcesPropertyResolver - Could not find key 'banner.image.location' in any property source
2018-10-30 14:37:17.242 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.location' in [servletConfigInitParams]
2018-10-30 14:37:17.242 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.location' in [servletContextInitParams]
2018-10-30 14:37:17.242 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.location' in [systemProperties]
2018-10-30 14:37:17.243 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.location' in [systemEnvironment]
2018-10-30 14:37:17.243 [main] TRACE o.s.core.env.PropertySourcesPropertyResolver - Searching for key 'banner.location' in [random]



application.properties配置:

server.port=8769

spring.datasource.url=jdbc:oracle:thin:@128.1.108.3:1521:pbdas
spring.datasource.username=userTest
spring.datasource.password=userTest
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

logging.level.root=info
#logging.level.org.springframework.web=info
#logging.file=logs/spring-boot-logging.log



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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.is</groupId>
<artifactId>InterfaceService</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath />
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
</properties>

<dependencies>
<!-- spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

-->


<!-- http -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.4</version>
</dependency>
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.11</version>
</dependency>
-->

<!-- JSON -->

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.1.41</version>
</dependency>

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>


<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>

<!-- JDBC -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>


<!--工具类 -->



<dependency>
<groupId>COM.CCB</groupId>
<artifactId>EnDecryptAlgorithm</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/COM.CCB.EnDecryptAlgorithm_v1.0_20120220.jar</systemPath>
</dependency>

<dependency>
<groupId>netpay.merchant</groupId>
<artifactId>netpay</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/netpay.jar</systemPath>
</dependency>


<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprovjdk14</artifactId>
<version>128</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bcprovjdk14-128.jar</systemPath>
</dependency>

</dependencies>


<build>
<finalName>InterfaceServer</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
<resources>
<!-- -->
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>

<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>


</project>

logback配置:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="logs/" />
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/logBack_log_%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>

<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>

</configuration>

...全文
380 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
WillingGatsby 2021-10-21
  • 打赏
  • 举报
回复

您好 您这个问题解决了么 我也遇到了

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧