Domanda

Io uso Boot Spring 1.2.1.Release e notato che la molla modifica automaticamente la mia configurazione LOG4J all'avvio.

Ecco le mie dipendenze (primavera):

<!-- parent includes slf4j and log4j -->
<dependencies>
    <dependency>
        <!-- Import dependency management from Spring Boot -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>1.1.2.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.1.2.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>de.komoot.wanderwalter</groupId>
        <artifactId>wanderwalter-api-models</artifactId>
        <version>1.26-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>de.komoot.wanderwalter</groupId>
        <artifactId>wanderwalter-routing</artifactId>
        <version>1.26-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.graphhopper</groupId>
        <artifactId>graphhopper</artifactId>
        <version>0.3-kmt</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
</dependencies>

<dependencyManagement>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.8</version>
        </dependency>
    </dependencies>
</dependencyManagement>
.

Quando avvio la mia applicazione con -Dlog4j.configuration=log4j-live.xml -Dlog4j.debug posso vedere che prima viene utilizzata la mia configurazione del mio log4j, quindi la molla pulisce e installa la propria configurazione e quindi (questo è ciò che immagino) aggiunge il log4j.xml predefinito. .

Come posso utilizzare solo il comportamento di log4j predefinito o come posso definire quale delle mie file Spring deve utilizzare per la configurazione?

Saluti,

Jan

È stato utile?

Soluzione

Boot a molla utilizza una proprietà del sistema di registrazione-Agnostico per sovrascrivere la configurazione predefinita:

.

Se l'ambiente contiene una proprietà logging.config, quindi verrà utilizzato per inizializzare il sistema di registrazione, altrimenti viene utilizzata una posizione predefinita.

Quindi usa invece -Dlogging.config=log4j-live.xml -Dlog4j.debug.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top