简体   繁体   English

日志记录系统无法使用来自“null”的配置进行初始化

[英]Logging system failed to initialize using configuration from 'null'

Hi Im making a big MVC project and now I'm trying to implement a logging functionallity through.xml file.您好我正在制作一个大型 MVC 项目,现在我正在尝试通过 .xml 文件实现日志记录功能。 I've triple checked the heading for typos and tried using differend encodings but nothing worked.我已经三次检查了标题是否有拼写错误,并尝试使用不同的编码,但没有任何效果。 I've added appenders for RollingFile and ConsoleAppender.I want to make a log containing name,date and level.I think thats all我为 RollingFile 和 ConsoleAppender 添加了 appender。我想创建一个包含名称、日期和级别的日志。我想就这些了

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <property name="LOG_FILE" value="logs/app.log"/>

    <appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>logs/archived/app.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <!-- each archived file, size max 5KB -->
            <maxFileSize>5KB</maxFileSize>
            <!-- total size of all archive files, if total size > 20KB,
                it will delete old archived file -->
            <totalSizeCap>20KB</totalSizeCap>
            <!-- 60 days to keep -->
            <maxHistory>60</maxHistory>
        </rollingPolicy>

        <encoder>
            <pattern>%d %p %c{1.} [%t] %m%n</pattern>
        </encoder>
    </appender>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
                %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
            </Pattern>
        </layout>
    </appender>




    <logger name="com.dailycodebuffer" level="error" additivity="false">
        <appender-ref ref="EMAIL"/>
    </logger>

    <logger name="com.dailycodebuffer" level="trace" additivity="false">
        <appender-ref ref="FILE-ROLLING"/>
    </logger>

    <root level="error">
        <appender-ref ref="FILE-ROLLING"/>
    </root>

    <logger name="com.dailycodebuffer" level="debug" additivity="false">
        <appender-ref ref="CONSOLE"/>
    </logger>
    <root level="error">
        <appender-ref ref="CONSOLE"/>
    </root>

</configuration>

the error im getting我得到的错误

 Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Could not initialize Logback logging from classpath:logback.xml
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:240)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:307)
    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:186)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    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.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:352)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at com.myfirm.CarDealer.CarDealerApplication.main(CarDealerApplication.java:10)
Caused by: ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. See previously reported errors.
    at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:71)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.populateSaxEventRecorder(GenericXMLConfigurator.java:178)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:159)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:260)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:237)
    ... 24 more
Caused by: org.xml.sax.SAXParseException; systemId: file:/C:/gitlabProjects/project1/car_dealer/cardealer/target/classes/logback.xml; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog.
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1251)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
    at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:64)
    ... 30 more

It looks You have space at start of logback.xml error: lineNumber: 1; columnNumber: 39; Content is not allowed in prolog.看起来你在 logback.xml 错误的开头有空间: lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. remove it lineNumber: 1; columnNumber: 39; Content is not allowed in prolog.请将其删除

I added space in my config and inteliJ highlighted it as error我在配置中添加了空间,inteliJ 将其突出显示为错误智能错误提示

, also running app returns similar problem as Yours ,也运行应用程序返回类似的问题作为你的

I fixed it by deleting the whole xml version and encoding我通过删除整个 xml 版本和编码来修复它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 日志系统无法使用“classpath:logger/logback-spring.xml”中的配置进行初始化 - Logging system failed to initialize using configuration from 'classpath:logger/logback-spring.xml' Artifactory无法初始化:上下文为空 - Artifactory failed to initialize: Context is null 防止导入的库使用我的日志配置文件 - Prevent imported libraries from using my logging-configuration file Dropwizard:无法解析配置:logging.appenders - Dropwizard: Failed to parse configuration at: logging.appenders 在没有XML配置的情况下初始化数据库,但使用@Configuration - Initialize database without XML configuration, but using @Configuration logback-spring.xml 级别配置中的“java.lang.IllegalStateException:无法从类路径初始化 Logback 日志记录:logback-spring.xml” - "java.lang.IllegalStateException: Could not initialize Logback logging from classpath:logback-spring.xml" in logback-spring.xml level configuration 从JAR记录系统指标 - Logging System Metrics from JAR java.util.logging.SimpileFormatter系统属性配置 - java.util.logging.SimpileFormatter system property configuration Spring Boot启动时禁用日志记录系统调试(配置转储) - Disable logging system debug (configuration dump) when spring boot starts 尝试使用TestNG执行跨浏览器测试脚本,但给出错误“失败的配置:@BeforeTest Browser(null)” - Trying to execute cross browser testing script using TestNG but giving error “FAILED CONFIGURATION: @BeforeTest Browser(null)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM