Bonjour,
je vous expose le problème que je rencontre :

(1.)L'application sur laquelle je travaille :
C'est une application web, avec des services REST.
Les technologies utilisées :
  • La base de données : mysql
  • Le serveur d'application : tomcat
  • Le logueur : log4j2
  • Le gestionnaire de dépendances : maven
  • Le framework : spring-boot


(2.)Le fichier pom.xml de mon application :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<project xmlns="http://maven.apache.org/POM/4.0.0" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
	<modelVersion>4.0.0</modelVersion>
 
	<groupId>afpa.cdi.banque</groupId>
	<artifactId>GestionBancaireSpringBoot</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
 
	<name>GestionBancaireSpringBoot Maven Webapp</name>
	<description>Gestion d'activités bancaires</description>
	<url>http://maven.apache.org</url>
 
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.1.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
 
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>
 
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-rest</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
 
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
 
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
 
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>
		<dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-slf4j-impl</artifactId>
		</dependency>
 
		<dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-api</artifactId>
		</dependency>		
		<dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-core</artifactId>
		</dependency>
		<dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-jcl</artifactId>
		</dependency>		
 
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<exclusions>
				<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-log4j2</artifactId>
		</dependency>		
 
		<!-- dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency -->
 
		<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 -->
		<!-- dependency>
			<groupId>org.thymeleaf.extras</groupId>
			<artifactId>thymeleaf-extras-springsecurity4</artifactId>
			<version>2.1.2.RELEASE</version>
		</dependency -->
	</dependencies>
 
	<build>
		<finalName>GestionBancaireSpringBoot</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
 
			<plugin>
			    <artifactId>maven-compiler-plugin</artifactId>
			    <configuration>
			        <source>1.8</source>
			        <target>1.8</target>
			    </configuration>
			</plugin>			
		</plugins>
	</build>
</project>
(3.)Le fichier application.properties de mon application :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
spring.datasource.url=jdbc:mysql://localhost:3306/banquedb?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
 
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
 
logging.config=classpath:log4j2-spring.xml
(4.)L'emplacement des fichiers évoqués précédemment :
  • Le fichier pom.xml : à la racine du projet.
  • Le fichier application.properties : dans le répertoire "src\main\resources".
  • Le fichier log4j2-spring.xml : dans le répertoire "src\main\resources".


(5.)La compilation du projet :
  • Le projet est compilé avec maven : "mvn clean install -e -X"
  • Le fichier exécutable est généré : "GestionBancaireSpringBoot.war"
  • Les 2 fichiers de log sont créés et remplis : "banquedb-application.log" et "banquedb-springboot.log".

(6.)L'exécution du projet :
  • L'application est déployée sur tomcat.
  • Les appels REST sont reçus par l'application.
  • Les logs produits par mon code : ils sont affichés dans la console.
  • Le fichier de log "banquedb-springboot.log" : il continue de se remplir (mais les logs ne proviennent pas de mon code).
  • Le fichier de log "banquedb-application.log" : il ne se remplit pas (je m'attendais à y voir les logs provenant de de mon code).


(7.)Le comportement espéré :
Les logs produits par mon code : je souhaiterais qu'ils soient logués dans le fichier "banquedb-application.log".
Cela ne se fait pas (les logs sont affichés dans la console uniquement).
Y a-t-il un moyen de corriger ce comportement indésirable ?
Pourriez-vous me donner des pistes pour que je cherche l'erreur, SVP ?
Merci d'avance pour vos aides...
chat_roux