2

我正在尝试使用 logback-logstash 编码器在 POC 应用程序中配置可配置的 JSON 日志。尽管我已经定义了所有建议的依赖项,并将日志配置减少到只有一个记录器和附加程序(以尝试隔离问题),但我仍然收到“找不到附加程序 x。你是在上面还是下面定义了它......”

我已经尝试逐步删除所有其他记录器/附加器,直到留下一个“找不到”的记录器。我在记录器定义中引用之前多次检查了附加程序是否已定义。我目前正在运行测试,所以我创建了一个显式的 logback-tests.xml,其配置与 logback.xml 相同。我最初在里面设置了所有依赖项,但是按照 logback-logstash 编码器文档中的说明,我最好让它们由 dependencyManagement 管理

依赖项:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
</properties>
... 
    <logback.jackson.json>0.1.5</logback.jackson.json>
    <logstash-logback-encoder.version>5.2</logstash-logback-encoder.version>
    <ch.qos.logback.version>1.2.3</ch.qos.logback.version>
</properties>

<dependencyManagement>
...
   <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${ch.qos.logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${ch.qos.logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-access</artifactId>
            <version>${ch.qos.logback.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>    

<dependencies>
...
    <!-- ======= -->
    <!-- Logging -->
    <!-- ======= -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback.contrib</groupId>
        <artifactId>logback-jackson</artifactId>
        <version>${logback.jackson.json}</version>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback.contrib</groupId>
        <artifactId>logback-json-classic</artifactId>
        <version>${logback.jackson.json}</version>
    </dependency>

    <dependency>
        <groupId>net.logstash.logback</groupId>
        <artifactId>logstash-logback-encoder</artifactId>
        <version>${logstash-logback-encoder.version}</version>
    </dependency>
...
</dependencies>

代码:

@Service
public class UserService {
....
private final Logger log = LoggerFactory.getLogger("AuditLogger");

  public User findByUsername(String username){

      User user = userRepo.findByUsername(username);
      log.info("method triggered");
      return user;
  }
}


@RunWith(SpringRunner.class)
@SpringBootTest
public class UserServiceTest {

@Autowired
private UserService userService;

@Test
public void  testFindUser(){
    Assert.assertNotNull(userService.findByUsername("jason.hickle"));
}

}

Logback.xml 配置:

<configuration debug="true" scan="true" scanPeriod="60 seconds">
<!--scanning picks up configuraiton changes at runtime, following he interval-->

<property name="LOG_DIR" value="./logs"></property>

<property name="LOG_FILE" value="LogFile" />

<appender name="PLAIN_FILE_JSON " class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>@{LOG_DIR}/tests.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <FileNamePattern>@{LOG_FILE}.json.log.%i</FileNamePattern>
        <maxIndex>10</maxIndex>
    </rollingPolicy>
    <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <MaxFileSize>20MB</MaxFileSize>
    </triggeringPolicy>
</appender>


<logger name="AuditLogger" level="DEBUG" additivity="false">
    <appender-ref ref="PLAIN_FILE_JSON"/>
</logger>

 edu.octavian.management.UserServiceTest,testFindUser

12:41:38,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:41:38,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
12:41:38,122 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Repository/Management/target/classes/logback.xml]
12:41:38,263 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:/C:/Repository/Management/target/classes/logback.xml] 
12:41:38,263 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 1 minutes
12:41:38,263 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] to configuration watch list.
12:41:38,263 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@548a9f61 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] is not of type file
12:41:38,263 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
12:41:38,263 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@548a9f61 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
12:41:38,278 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
12:41:38,278 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
12:41:38,278 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wEx with class [org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter]
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http11.Http11NioProtocol] to WARN
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
12:41:38,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
12:41:38,278 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
12:41:38,278 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@548a9f61 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
12:41:38,294 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:41:38,294 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
12:41:38,294 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:41:38,356 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] to configuration watch list.
12:41:38,356 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@548a9f61 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] is not of type file
12:41:38,356 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:41:38,356 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
12:41:38,356 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:41:38,372 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@157683534 - Archive files will be limited to [10 MB] each.
12:41:38,372 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@157683534 - Will use gz compression
12:41:38,372 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@157683534 - Will use the pattern C:/Users/octavian/AppData/Local/Temp//spring.log.%d{yyyy-MM-dd}.%i for the active file
12:41:38,372 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@23faf8f2 - The date pattern is 'yyyy-MM-dd' from file name pattern 'C:/Users/octavian/AppData/Local/Temp//spring.log.%d{yyyy-MM-dd}.%i.gz'.
12:41:38,372 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@23faf8f2 - Roll-over at midnight.
12:41:38,388 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@23faf8f2 - Setting initial period to Sun Jan 20 12:29:56 EET 2019
12:41:38,388 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: C:\Users\octavian\AppData\Local\Temp\/spring.log
12:41:38,388 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [C:\Users\octavian\AppData\Local\Temp\/spring.log]
12:41:38,388 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
12:41:38,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
12:41:38,388 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
12:41:38,388 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:41:38,388 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [PLAIN_FILE_JSON ]
12:41:38,403 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@1786dec2 - No compression will be used
12:41:38,700 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[PLAIN_FILE_JSON ] - Active log file name: @{LOG_DIR}/tests.log
12:41:38,700 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[PLAIN_FILE_JSON ] - File property is set to [@{LOG_DIR}/tests.log]
12:41:38,700 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [AuditLogger] to DEBUG
12:41:38,700 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [AuditLogger] to false
12:41:38,700 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [PLAIN_FILE_JSON]. Did you define it below instead of above in the configuration file?
12:41:38,700 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
12:41:38,700 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
12:41:38,700 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@2bbf180e - Registering current configuration as safe fallback point
2019-01-20 12:41:38.950  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Neither @ContextConfiguration nor @ContextHierarchy found for test class [edu.octavian.management.UserServiceTest], using SpringBootContextLoader
2019-01-20 12:41:38.966  INFO   --- [           main] o.s.t.c.support.AbstractContextLoader    : Could not detect default resource locations for test class [edu.octavian.management.UserServiceTest]: no resource found for suffixes {-context.xml, Context.groovy}.
2019-01-20 12:41:38.966  INFO   --- [           main] t.c.s.AnnotationConfigContextLoaderUtils : Could not detect default configuration classes for test class [edu.octavian.management.UserServiceTest]: UserServiceTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2019-01-20 12:41:39.247  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Found @SpringBootConfiguration edu.octavian.management.ManagementApplication for test class edu.octavian.management.UserServiceTest
2019-01-20 12:41:39.403  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
2019-01-20 12:41:39.419  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@61710c6, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3214ee6, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@383dc82c, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@4a07d605, org.springframework.test.context.support.DirtiesContextTestExecutionListener@74287ea3, org.springframework.test.context.transaction.TransactionalTestExecutionListener@7d7758be, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2bdd8394, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@5f9edf14, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@68746f22, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@2f01783a, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@68878f6d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@41488b16]12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:/C:/Repository/Management/target/classes/logback.xml] 
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 1 minutes
12:41:39,747 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] to configuration watch list.
12:41:39,747 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@421bba99 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/base.xml] is not of type file
12:41:39,747 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
12:41:39,747 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@421bba99 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
12:41:39,747 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
12:41:39,747 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
12:41:39,747 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wEx with class [org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter]
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating ERROR level on Logger[org.apache.catalina.startup.DigesterFactory] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating ERROR level on Logger[org.apache.catalina.util.LifecycleBase] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http11.Http11NioProtocol] to WARN
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating WARN level on Logger[org.apache.coyote.http11.Http11NioProtocol] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating WARN level on Logger[org.apache.sshd.common.util.SecurityUtils] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating WARN level on Logger[org.apache.tomcat.util.net.NioSelectorPool] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating ERROR level on Logger[org.eclipse.jetty.util.component.AbstractLifeCycle] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
12:41:39,747 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating WARN level on Logger[org.hibernate.validator.internal.util.Version] onto the JUL framework
12:41:39,747 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
12:41:39,747 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@421bba99 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:41:39,762 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@4f933fd1 - Adding [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] to configuration watch list.
12:41:39,762 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@421bba99 - URL [jar:file:/C:/Users/octavian/.m2/repository/org/springframework/boot/spring-boot/2.1.1.RELEASE/spring-boot-2.1.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] is not of type file
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
12:41:39,762 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:41:39,762 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1327234595 - Archive files will be limited to [10 MB] each.
12:41:39,762 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1327234595 - Will use gz compression
12:41:39,762 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1327234595 - Will use the pattern C:/Users/octavian/AppData/Local/Temp//spring.log.%d{yyyy-MM-dd}.%i for the active file
12:41:39,762 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@e19bb76 - The date pattern is 'yyyy-MM-dd' from file name pattern 'C:/Users/octavian/AppData/Local/Temp//spring.log.%d{yyyy-MM-dd}.%i.gz'.
12:41:39,762 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@e19bb76 - Roll-over at midnight.
12:41:39,762 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@e19bb76 - Setting initial period to Sun Jan 20 12:41:39 EET 2019
12:41:39,809 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: C:\Users\octavian\AppData\Local\Temp\/spring.log
12:41:39,809 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [C:\Users\octavian\AppData\Local\Temp\/spring.log]
12:41:39,809 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
12:41:39,809 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating INFO level on Logger[ROOT] onto the JUL framework
12:41:39,809 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
12:41:39,809 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
12:41:39,809 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:41:39,809 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [PLAIN_FILE_JSON ]
12:41:39,809 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@71529963 - No compression will be used
12:41:39,809 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[PLAIN_FILE_JSON ] - Active log file name: @{LOG_DIR}/tests.log
12:41:39,809 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[PLAIN_FILE_JSON ] - File property is set to [@{LOG_DIR}/tests.log]
12:41:39,809 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [AuditLogger] to DEBUG
12:41:39,809 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@31bcf236 - Propagating DEBUG level on Logger[AuditLogger] onto the JUL framework
12:41:39,809 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [AuditLogger] to false
12:41:39,809 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [PLAIN_FILE_JSON]. Did you define it below instead of above in the configuration file?
12:41:39,809 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
12:41:39,809 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
12:41:39,809 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@22295ec4 - Registering current configuration as safe fallback point
2019-01-20 12:41:40.122 ERROR 10428 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [PLAIN_FILE_JSON]. Did you define it below instead of above in the configuration file?
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.

    --spring boot wrapper errors--

2019-01-20 12:41:40.122 ERROR 10428 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@61710c6] to prepare test instance [edu.octavian.management.UserServiceTest@5dd1c9f2]
4

2 回答 2

4

在 logback.xml 中,appender 的 name 属性末尾有一个空格,因此将其命名为"PLAIN_FILE_JSON "

您在没有空格的情况下引用它(我猜这是无意的)。

于 2019-01-20T11:06:16.413 回答
-5

您缺少日志 API jar!

于 2019-12-17T08:43:30.247 回答