我正在使用azure应用程序见解来登录我的应用程序,这是一个带有gradle的spring boot应用程序。我在logback.xml中将应用程序见解用作附加程序 该应用程序正常运行,并且日志记录正常运行。但是,当我尝试使用“ gradle build”构建应用程序时,该构建会卡住并永久运行。
如果从logback.xml文件中删除了应用程序见解附加程序,则应用程序将正常运行。我尝试添加ApplicationInsights.xml,但问题仍然存在
我的build.gradle如下。
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "http://repo.spring.io/plugins-release" }
maven { url "http://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}"
classpath "io.spring.gradle:propdeps-plugin:${propdeps_plugin_version}"
classpath "gradle.plugin.org.detoeuf:swagger-codegen-plugin:${swagger_codegen_version}"
classpath "net.ltgt.gradle:gradle-apt-plugin:${net_ltgt_version}"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${sonar_version}"
}
}
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.apt'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
group = 'com.test.project'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven { url "https://repo.spring.io/milestone" }
mavenLocal()
flatDir {
dirs 'libs'
}
}
dependencies {
api "org.springframework.boot:spring-boot-starter-web"
api "org.springframework.boot:spring-boot-starter-actuator"
api "org.springframework.boot:spring-boot-starter-jetty"
api "org.springframework.boot:spring-boot-starter-data-jpa"
api "org.springframework.boot:spring-boot-starter-security"
api "org.springframework.security.oauth:spring-security-oauth2"
api "org.springframework.cloud:spring-cloud-starter-config"
api "org.springframework.cloud:spring-cloud-security:${spring_cloud_security_version}"
api "io.springfox:springfox-swagger2:${swagger_version}"
api "io.springfox:springfox-swagger-ui:${swagger_version}"
api ("net.sf.dozer:dozer:${dozer_version}") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
api "com.zaxxer:HikariCP:${hikari_version}"
api "org.postgresql:postgresql:${postgres_version}"
api "org.hibernate:hibernate-java8"
api "io.jsonwebtoken:jjwt:0.9.0"
api "org.springframework.boot:spring-boot-starter-quartz"
api "org.quartz-scheduler:quartz:2.2.3"
api "org.quartz-scheduler:quartz-jobs:2.2.3"
api "org.springframework:spring-jdbc:4.2.4.RELEASE"
api "com.microsoft.azure:applicationinsights-spring-boot-starter:1.0.0-BETA"
api "com.microsoft.azure:applicationinsights-logging-logback:2.0.+"
compileOnly "org.projectlombok:lombok:${lombok_version}"
annotationProcessor "org.projectlombok:lombok:${lombok_version}"
// Use JUnit test framework
testImplementation "junit:junit:${junit_version}"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "javax.servlet:javax.servlet-api:${javax_servlet_version}"
testImplementation "io.rest-assured:rest-assured:${rest_assured_version}"
testImplementation "io.rest-assured:spring-mock-mvc:${rest_assured_version}"
testImplementation "com.h2database:h2"
testImplementation "org.hsqldb:hsqldb"
testImplementation "com.github.tomakehurst:wiremock:2.6.0"
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
}
dependencyManagement {
imports {
mavenBom "com.microsoft.azure:azure-spring-boot-bom:${spring_azure_version}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}"
}
}
我的logback.xml是
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_FILE" value="logs/project_name" />
<property name="LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n" />
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>${LOG_PATTERN}</pattern>
</layout>
</appender>
<appender name="ROLLINGFILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd-HH}.%i.log</fileNamePattern>
<maxHistory>10</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<appender name="aiAppender"
class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
</appender>
<root level="ERROR">
<appender-ref ref="CONSOLE" />
<appender-ref ref="ROLLINGFILE" />
<appender-ref ref="aiAppender" />
</root>
<logger name="org.springframework" level="ERROR" />
<logger name="org.hibernate.engine" level="ERROR" />
</configuration>
我的application.yml属性是
project:
artifactId: project-artifact
name: Project name
version: 0.0.1-SNAPSHOT
description: Project desc
server:
port: 8080
servlet:
contextPath: /api
azure:
application-insights:
instrumentation-key: instrumentation-key
enabled: true
web:
enabled: true
我尝试按如下所示添加ApplicationInsights.xml,但构建仍挂起
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
<!-- The key from the portal: -->
<InstrumentationKey>instrumentation key</InstrumentationKey>
<!-- HTTP request component (not required for bare API) -->
<TelemetryModules>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
</TelemetryModules>
<!-- Events correlation (not required for bare API) -->
<!-- These initializers add context data to each event -->
<TelemetryInitializers>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
</TelemetryInitializers>
</ApplicationInsights>
请建议我是否有任何遗物
答案 0 :(得分:0)
通过将logback.xml更改为logback-spring.xml来解决问题