質問編集履歴
1
Logback形式のxml作成
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,3 +125,103 @@
|
|
125
125
|
|
126
126
|
|
127
127
|
そもそもxmlが読み込まれていないと思い「src/main/resources/log4j.xml」にも配置してみたのですが、意味がありませんでした。
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
##2020/02/17追記
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
```logbackxml
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
142
|
+
|
143
|
+
<configuration>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<!-- for debug -->
|
148
|
+
|
149
|
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
150
|
+
|
151
|
+
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
152
|
+
|
153
|
+
<layout class="com.example.demo.AppLog" />
|
154
|
+
|
155
|
+
</encoder>
|
156
|
+
|
157
|
+
</appender>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<!-- log file -->
|
162
|
+
|
163
|
+
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
164
|
+
|
165
|
+
<file>C:\Users\Desktop\messages.log</file>
|
166
|
+
|
167
|
+
<append>true</append>
|
168
|
+
|
169
|
+
<layout class="com.example.demo.AppLog" />
|
170
|
+
|
171
|
+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<!-- daily rollover -->
|
176
|
+
|
177
|
+
<fileNamePattern>${LOG_DIR}/messages.%d{yyyy-MM-dd}.log</fileNamePattern>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<!-- keep 90 days' worth of history -->
|
182
|
+
|
183
|
+
<maxHistory>90</maxHistory>
|
184
|
+
|
185
|
+
</rollingPolicy>
|
186
|
+
|
187
|
+
</appender>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<!-- syslog ←この設定が入ると、SUDOUTとFILEがINFOレベルでも出力されなくなる -->
|
194
|
+
|
195
|
+
<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
|
196
|
+
|
197
|
+
<syslogHost>localhost</syslogHost>
|
198
|
+
|
199
|
+
<facility>local6</facility>
|
200
|
+
|
201
|
+
<suffixPattern>[%thread] %logger %msg</suffixPattern>
|
202
|
+
|
203
|
+
</appender>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<root level="DEBUG">
|
208
|
+
|
209
|
+
<appender-ref ref="STDOUT" />
|
210
|
+
|
211
|
+
<appender-ref ref="FILE" />
|
212
|
+
|
213
|
+
</root>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<root level="ERROR">
|
218
|
+
|
219
|
+
<appender-ref ref="SYSLOG" />
|
220
|
+
|
221
|
+
</root>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</configuration>
|
226
|
+
|
227
|
+
```
|