我是靠谱客的博主 落寞冬天,这篇文章主要介绍ERROR StatusLogger Log4j2 could not find a logging implementation.,现在分享给大家,希望可以做个参考。

今天在学习structs2  2.5.5的版本的时候碰到2个问题。第一个网上下的包里面差log4j-core这个包。

虽然程序可以运行,但控制台会报这个错误。

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

在添加了这个包后在再次运行程序。

控制台提示

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

找不到log4j2的配置文件

网上google之。找到文档。原来只要在classpath下的目录添加一个log4j2.xml。就可以了

复制代码
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Configuration status="warn">
  3.              <Appenders>
  4.                          <Console name="Console" target="SYSTEM_OUT">
  5.                                      <PatternLayout pattern="[%-5p] %d %c - %m%n" />
  6.                          </Console>
  7.                          <File name="File" fileName="dist/my.log">
  8.                                      <PatternLayout pattern="%m%n" />
  9.                          </File>
  10.              </Appenders>
  11.              <Loggers>
  12.                          <Logger name="mh.sample2.Log4jTest2" level="INFO">
  13.                                      <AppenderRef ref="File" />
  14.                          </Logger>
  15.                          <Root level="INFO">
  16.                                      <AppenderRef ref="Console" />
  17.                          </Root>
  18.              </Loggers>
  19. </Configuration>

这里为什么这样配置就不说了,可以去查阅log4j2的文档。

在次运行程序,控制台没有错误提示了

我果然还是java菜鸟一个啊,这里只是自己的学习记录,哈哈,大神别喷。

原文:http://xtceetg.blog.51cto.com/5086648/1877001

最后

以上就是落寞冬天最近收集整理的关于ERROR StatusLogger Log4j2 could not find a logging implementation.的全部内容,更多相关ERROR内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部