logback配置错误

Posted svygh123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了logback配置错误相关的知识,希望对你有一定的参考价值。

09:18:09,724 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:18:09,724 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:18:09,725 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/devtools/eclipse2012/workspace/dataimport/target/classes/logback.xml]
09:18:09,850 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:18:09,860 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:18:09,866 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [stdout]
09:18:09,875 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
09:18:09,977 |-WARN in ch.qos.logback.core.ConsoleAppender[stdout] - This appender no longer admits a layout as a sub-component, set an encoder instead.
09:18:09,977 |-WARN in ch.qos.logback.core.ConsoleAppender[stdout] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
09:18:09,977 |-WARN in ch.qos.logback.core.ConsoleAppender[stdout] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
09:18:09,978 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
09:18:09,987 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [appLogAppender]
09:18:09,990 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
09:18:10,038 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2136288211 - No compression will be used
09:18:10,040 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2136288211 - Will use the pattern /logs/dataimport/log-%dyyyy-MM-dd-%i.log for the active file
09:18:10,044 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@3c22fc4c - The date pattern is 'yyyy-MM-dd' from file name pattern '/logs/dataimport/log-%dyyyy-MM-dd-%i.log'.
09:18:10,044 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@3c22fc4c - Roll-over at midnight.
09:18:10,050 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@3c22fc4c - Setting initial period to Wed Feb 24 09:18:10 CST 2021
09:18:10,050 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@3c22fc4c - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
09:18:10,050 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@3c22fc4c - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
09:18:10,055 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[appLogAppender] - This appender no longer admits a layout as a sub-component, set an encoder instead.
09:18:10,055 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[appLogAppender] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
09:18:10,055 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[appLogAppender] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
09:18:10,061 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[appLogAppender] - Active log file name: /logs/dataimport/log.log
09:18:10,061 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[appLogAppender] - File property is set to [/logs/dataimport/log.log]
09:18:10,065 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
09:18:10,065 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [stdout] to Logger[ROOT]
09:18:10,066 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [appLogAppender] to Logger[ROOT]
09:18:10,066 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:18:10,068 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@460d0a57 - Registering current configuration as safe fallback point

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:232)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:73)
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
	at com.ext.dataimport.DataimportApplication.main(DataimportApplication.java:35)
	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.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
2021-02-24 09:18:11.307 [restartedMain] DEBUG [o.springframework.boot.devtools.restart.Restarter : 252] - Creating new Restarter for thread Thread[main,5,main]
2021-02-24 09:18:11.311 [restartedMain] DEBUG [o.springframework.boot.devtools.restart.Restarter : 252] - Immediately restarting application
2021-02-24 09:18:11.311 [restartedMain] DEBUG [o.springframework.boot.devtools.restart.Restarter : 252] - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@2e730201
2021-02-24 09:18:11.311 [restartedMain] DEBUG [o.springframework.boot.devtools.restart.Restarter : 252] - Starting application com.ext.dataimport.DataimportApplication with URLs [file:/D:/devtools/eclipse2012/workspace/dataimport/target/classes/]
2021-02-24 09:18:11.352 [restartedMain] ERROR [org.springframework.boot.SpringApplication : 856] - Application run failed
java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:327)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
	at com.ext.dataimport.DataimportApplication.main(DataimportApplication.java:35)
	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.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:232)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:73)
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
	... 23 common frames omitted
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
	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.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:327)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
	at com.ext.dataimport.DataimportApplication.main(DataimportApplication.java:35)
	... 5 more
Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@13:13 - no applicable action for [Encoding], current ElementPath  is [[configuration][appender][Encoding]]
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:232)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:73)
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
	... 23 more

由于高版本不支持Encoding标签,去掉即可

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<property name="log.base" value="/logs/dataimport" />
	<property name="log.fileName" value="log" />
	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
		<!-- <Encoding>UTF-8</Encoding> -->
		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%dyyyy-MM-dd HH:mm:ss.SSS [%thread] %-5level [%logger50 : %line] - %msg%n</pattern>
		</layout>
	</appender>

	<appender name="appLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<!-- <Encoding>UTF-8</Encoding> -->
		<file>$log.base/$log.fileName.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>$log.base/$log.fileName-%dyyyy-MM-dd-%i.log</fileNamePattern>
			<MaxHistory>365</MaxHistory>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>
		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%dyyyy-MM-dd HH:mm:ss.SSS [ %thread ] - [ %-5level ] [ %logger50 : %line ] - %msg%n</pattern>
		</layout>
	</appender>
	
	<root level="DEBUG">
		<appender-ref ref="stdout" />
		<appender-ref ref="appLogAppender" />
	</root>
</configuration>

 

以上是关于logback配置错误的主要内容,如果未能解决你的问题,请参考以下文章

Logback日志系统

Spring Boot中实现logback多环境日志配置

Flink(1.12.1)日志配置Logback实现日志切分和kafka发送

Logback 的 Syslog Appender

Logback日志输出问号的问题解决方案

logback怎么根据logger输出不同文件