相关文章推荐
不羁的课本  ·  MySQL ...·  1 月前    · 
英勇无比的玉米  ·  Weird behaviour of ...·  1 年前    · 
听话的楼房  ·  SQLite Database Speed ...·  1 年前    · 

springboot集成logback,报错java.lang.IllegalStateException: Logback configuration error detected:

最新推荐文章于 2023-04-18 09:43:09 发布
最新推荐文章于 2023-04-18 09:43:09 发布 12117

最近需要将一个springboot项目部署到一台新服务器上。而且新服务器是完全copy了旧服务器的环境与项目。但是在新服务器上启动该springboot项目,就一直报错

2019-03-18 18:54:35.532 [main] ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:13 - RuntimeException in Action for tag [appender] java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:81)
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:59)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
	at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:303)
	at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
	at com.xhl.leads.leadsmail.LeadsMailApplication.main(LeadsMailApplication.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
	at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:587)

看上面报错信息说是数据库相关的问题。找到项目集成的logback-spring.xml,然后搜索DBAppender这个类,猜测是在链接数据库时有问题。于是和运维人员确认了一下该配置文件连接的数据库服务器的防火墙。经查看,该数据库的防火墙,对于访问ip有限制。将新服务器的ip加入数据库服务器的防火墙里,项目就能正常启动了。

附赠:logback-spring.xml配置文件。注意:该配置文件中有需要自己改动的地方:例如"项目名","数据库ip","数据库用户名","数据库密码","数据库库名"

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>DENY</onMatch>
            <onMismatch>ACCEPT</onMismatch>
        </filter>
        <encoder>
      		<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    	</encoder>
        <!--滚动策略-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--路径-->
            <fileNamePattern>/var/log/项目名/info.%d.log</fileNamePattern>
        </rollingPolicy>
    </appender>
    <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
        <!--滚动策略-->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--路径-->
            <fileNamePattern>/var/log/项目名/error.%d.log</fileNamePattern>
        </rollingPolicy>
    </appender>
    <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
		<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
			<driverClass>com.mysql.jdbc.Driver</driverClass>
			<url>jdbc:mysql://数据库ip:3306/数据库库名?useUnicode=true&amp;characterEncoding=UTF-8</url>
			<user>数据库用户名</user>
			<password>数据库密码</password>
		</connectionSource>
	</appender>
	 <appender name ="ASYNC" class= "ch.qos.logback.classic.AsyncAppender">  
            <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->  
            <discardingThreshold >0</discardingThreshold>  
            <!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->  
            <queueSize>512</queueSize>  
            <!-- 添加附加的appender,最多只能添加一个 -->  
         <appender-ref ref ="DB"/>  
     </appender>  
    <root level="info">
        <appender-ref ref="consoleLog" />
    </root>
    <logger name="com.alibaba.druid" level="error" additivity="false">
		<appender-ref ref="consoleLog" />
		<appender-ref ref="fileErrorLog" />
	</logger>
	<logger name="org.springframework" level="error" additivity="false">
		<appender-ref ref="consoleLog" />
		<appender-ref ref="fileErrorLog" />
	</logger>
	<logger name="org.hibernate" level="error" additivity="false">
		<appender-ref ref="consoleLog" />
		<appender-ref ref="fileErrorLog" />
	</logger>
	<logger name="org.apache" level="error" additivity="false">
		<appender-ref ref="consoleLog" />
		<appender-ref ref="fileErrorLog" />
	</logger>
	<logger name="com.xhl.cuss" level="info" additivity="false">
	    <appender-ref ref="fileInfoLog" />
		<appender-ref ref="fileErrorLog" />
		<appender-ref ref="consoleLog" />
		<appender-ref ref="ASYNC" />
	</logger>
</configuration>
springboot集成logback,报错java.lang.IllegalStateException: Logback configuration error detected: 最近需要将一个springboot项目部署到一台新服务器上。而且新服务器是完全copy了旧服务器的环境与项目。但是在新服务器上启动该springboot项目,就一直报错2019-03-18 18:54:35.532 [main] ERROR o.s.boot.SpringApplication - Application startup failedjava.lang.Illegal...
问题1: Logging system fail ed to initialize using configuration from ' logback .xml ' applica tio n.prop er ties配置文件中value后面有空格。 logging.config= logback .xml 让人感到疑惑的是, SpringBoot 居然没有对applica tio n.prop er ties配置文件va
Android异常详情介绍 这种异常我遇到以下两种情况: 1. java . lan g. IllegalStateException : No wrapp ed connec tio n. 2. java . lan g. IllegalStateException : Adapt er is detach ed . 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会出现连接超时. 2.HttpConnec tio n没有连接池的概念,多少次请求就会建立多少个IO,在访问量巨大的情况下服务器的IO可能会耗尽。 3.通常是因为HttpClient访问单一实例的不同的线程或未关闭Input
1、错误信息 异常:Caus ed by: java . lan g. IllegalStateException : Method has too many Body paramet er s Caus ed by: java . lan g. IllegalStateException : Method has too many Body paramet er s: public abstract com.iot.framework.core.response.CommResponse com.iot.basic.config.api.client.configdata.PushRuleClient.getByEven
&lt;?xml v er sion="1.0" encoding="UTF-8"?&gt; &lt; configuration scan="true" scanP er iod="60"&gt; &lt; append er name="STDOUT" class="ch.qos. logback .core.Console Append er &qu
ERROR in ch.qos. logback .core.rolling.RollingFile Append er [S ER VICE] - Fail ed to create parent directories for [C:\Us er s\logs\s er vice\s er vice.log] ERROR in ch.qos. logback .core.rolling.RollingFile Append er ...
纠结了半天的 java . lan g. IllegalStateException : getOutputStream() has already。这个问题困扰了半天,在网上查阅了大量资料 出这个错误一般就是下面2个.....
下面的引用 SizeAndTimeBas ed RollingPolicy  只能是1.2版本以上 ,如果是spring start er 中已经引用了,直接修改日志版本号即可 即在pom中加入:    1.2.1 注意1:TimeBas ed RollingPolicy 和 SizeAndTimeBas ed RollingPolicy  的区别。 使用TimeBas ed Rolling
一、引入 Logback 日志的maven依赖: logback -classic<dependency> <groupId>ch.qos. logback </groupId> <artifactId> logback -classic</artifactId> </dependency>二、 Springboot Logba...
javamail以hotmail作为发件人时报错SMTPSendFailedException:STOREDRV.Submission.Exception:OutboundSpamException 19234 javamail写邮件/邮箱验证报错javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 16425 springboot集成logback,报错java.lang.IllegalStateException: Logback configuration error detected: 12114 javamail写邮件/邮箱验证报错javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 这个是配置好的。你看看帖子上面的应用图,这个ssl是需要用户手动勾选的 javamail写邮件/邮箱验证报错javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 哈登编程: 你好,怎么获取sendServerSslFlag怎么获取的啊,Java可以获取到邮箱是否打开ssl吗? 还是这个是配置好的 springboot集成logback,报错java.lang.IllegalStateException: Logback configuration error detected: Isabella斑: 呜呜呜呜呜呜呜移动项目之后改了两三天,看了你的帖子终于发现问题了,哭死我 javamail解析邮件,内容重复 哆啦A梦丶幻想: 好哦,谢谢 javamail解析邮件,内容重复 在我负责邮件功能期间,没有遇到这种情况