mirror of https://github.com/qos-ch/slf4j
Compare commits
568 Commits
v_1.8.0-be
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
61400453cd | |
|
|
58b66c2c7e | |
|
|
be4841cce8 | |
|
|
d2073bece8 | |
|
|
32a9854cf4 | |
|
|
77936c6f1f | |
|
|
34c9d30af5 | |
|
|
902b463957 | |
|
|
b3c2f16f12 | |
|
|
9468c7a28f | |
|
|
183aaa5070 | |
|
|
c233ea1932 | |
|
|
4b4d533771 | |
|
|
9349d64f95 | |
|
|
0def25ebfa | |
|
|
69c333de28 | |
|
|
2470fad4fd | |
|
|
c2c29fec98 | |
|
|
0597225b5b | |
|
|
f7b34c2e60 | |
|
|
4fa92fc007 | |
|
|
101086ba35 | |
|
|
8ae0efca23 | |
|
|
3ff00870b3 | |
|
|
0df43e9e53 | |
|
|
46b5ea54a6 | |
|
|
5321a975d4 | |
|
|
09111e8c1e | |
|
|
6a04f67fdd | |
|
|
03aa6b915a | |
|
|
7c3b0ef011 | |
|
|
42810107b0 | |
|
|
982e4b067f | |
|
|
dd4486b5c5 | |
|
|
1d82519b07 | |
|
|
5ffbc67def | |
|
|
3386517ad6 | |
|
|
448bca173c | |
|
|
955209464d | |
|
|
c1473c957a | |
|
|
98932348fb | |
|
|
c52da92599 | |
|
|
da91e4f219 | |
|
|
8c4ea8f225 | |
|
|
6b2921a523 | |
|
|
3f4717c44e | |
|
|
d9145fba56 | |
|
|
68ff7064ec | |
|
|
db8cd90c10 | |
|
|
d564304a61 | |
|
|
ef8dda71dd | |
|
|
fe42ecb5f7 | |
|
|
7029a8b7fd | |
|
|
8c873b2e75 | |
|
|
7bcee9aa1f | |
|
|
6fe9c07113 | |
|
|
df562c22d8 | |
|
|
6d39ca8bf9 | |
|
|
86ee8298d9 | |
|
|
5ccbe20b11 | |
|
|
02b36a269a | |
|
|
c12667b906 | |
|
|
316b5d1727 | |
|
|
7c164fab8d | |
|
|
56e42fdb61 | |
|
|
216459e5d8 | |
|
|
2481810f94 | |
|
|
25d742d666 | |
|
|
10a151756d | |
|
|
17f5bf3d87 | |
|
|
f967033766 | |
|
|
0b9c92cc3a | |
|
|
05698f8d23 | |
|
|
9783320b6c | |
|
|
aa13da39ed | |
|
|
7a4da876b3 | |
|
|
0769bc8182 | |
|
|
e63f87f02c | |
|
|
3f20e0dfd2 | |
|
|
06fa09a2fb | |
|
|
6fd9db9b5e | |
|
|
f871e7f2e9 | |
|
|
0b4d88edef | |
|
|
2ec7c1034c | |
|
|
df44ace9c3 | |
|
|
661869eeb2 | |
|
|
cff3312e43 | |
|
|
d6a21ae68f | |
|
|
13950e51a6 | |
|
|
122e0c18dd | |
|
|
2a8ca99caf | |
|
|
b363bb31ed | |
|
|
2235d3c698 | |
|
|
a5540ad510 | |
|
|
1ed084cbc0 | |
|
|
b2cb017422 | |
|
|
fa6721a53e | |
|
|
f85104040c | |
|
|
5ff6f2c385 | |
|
|
2f4aa75445 | |
|
|
363f0a534e | |
|
|
171679baa8 | |
|
|
921b5b31e1 | |
|
|
e02244c39f | |
|
|
441d4584be | |
|
|
f5e741ba1a | |
|
|
2e71327c8e | |
|
|
3ff2a30e05 | |
|
|
7e62e1e691 | |
|
|
d250ad79eb | |
|
|
3bc58f3e81 | |
|
|
207bb299c3 | |
|
|
35dd7ff1e7 | |
|
|
440c2f3000 | |
|
|
43a36303e5 | |
|
|
557bf7c0bd | |
|
|
632410565b | |
|
|
e540299d58 | |
|
|
dfb41b06a8 | |
|
|
47c7cc7fa4 | |
|
|
0be1bc15f2 | |
|
|
d60690c0b9 | |
|
|
6720d8db66 | |
|
|
72a0bc6528 | |
|
|
f276d52d96 | |
|
|
7cad6082dc | |
|
|
143978ce05 | |
|
|
88b0ee3c1f | |
|
|
b2cb05f16a | |
|
|
4b5bb41ede | |
|
|
b500a6fdfd | |
|
|
d81affb012 | |
|
|
bcbbe40ffd | |
|
|
7686020c36 | |
|
|
3f47f87ccc | |
|
|
eb1710af7b | |
|
|
bb49a5aeef | |
|
|
768ca7d4c0 | |
|
|
0645c18caf | |
|
|
894b1890a0 | |
|
|
7c1d86e21e | |
|
|
9752442b6e | |
|
|
c0f7f16bfb | |
|
|
1148b98529 | |
|
|
593f89f85a | |
|
|
03deea9f77 | |
|
|
c9d5cc1257 | |
|
|
bae56f544b | |
|
|
24788ac731 | |
|
|
05c0b0a881 | |
|
|
400a885e7d | |
|
|
a4f165689f | |
|
|
4685f1ebc0 | |
|
|
15d4c1fdd6 | |
|
|
42f863863f | |
|
|
51ceaf6224 | |
|
|
0614d467d7 | |
|
|
b1afcd01b1 | |
|
|
20cd3ad0ab | |
|
|
aeebb6199d | |
|
|
1068cd0eb9 | |
|
|
4e4e56a2df | |
|
|
0dcfa19040 | |
|
|
e7ca8d17c8 | |
|
|
2314de9dd9 | |
|
|
508a796552 | |
|
|
d93a5e0456 | |
|
|
43005d1d85 | |
|
|
14ec670971 | |
|
|
c0001d4619 | |
|
|
9feda2c795 | |
|
|
287fe4f97a | |
|
|
5537ff1699 | |
|
|
996866fae7 | |
|
|
ae032b1297 | |
|
|
6afe5ab7a7 | |
|
|
82a592ed79 | |
|
|
e454d28282 | |
|
|
db3835d392 | |
|
|
61574d22f4 | |
|
|
9dd3de0511 | |
|
|
6701960a59 | |
|
|
98728180ac | |
|
|
ac854c79ea | |
|
|
0c0eb1275d | |
|
|
2b0e15874a | |
|
|
045f502fa9 | |
|
|
a188a3ed73 | |
|
|
23182d4468 | |
|
|
aa0de34dc6 | |
|
|
5c4fe1d48c | |
|
|
90f3f1ea07 | |
|
|
5fcbb283a3 | |
|
|
956acb06d6 | |
|
|
6df6053c24 | |
|
|
74ccf20fab | |
|
|
8806a45ede | |
|
|
2287768293 | |
|
|
bef80280e6 | |
|
|
c1282ba08c | |
|
|
81a0568d68 | |
|
|
f04cf16b66 | |
|
|
c69570fc51 | |
|
|
85541d5669 | |
|
|
4835381767 | |
|
|
c9c5492ded | |
|
|
510cc99e37 | |
|
|
a20a22299d | |
|
|
2d6b6344f0 | |
|
|
16ab482cab | |
|
|
39a07b9ce4 | |
|
|
10bd70ca75 | |
|
|
66e9c2555f | |
|
|
28528094b9 | |
|
|
6abaf6897b | |
|
|
39cf0fc837 | |
|
|
0e04efdbf6 | |
|
|
0d4167abe7 | |
|
|
60e70fbc83 | |
|
|
9e4a358634 | |
|
|
f6076c1409 | |
|
|
34547b2f32 | |
|
|
ea47492d7a | |
|
|
f09e33dd15 | |
|
|
12b5a6b676 | |
|
|
23c8cc0121 | |
|
|
0877cb6410 | |
|
|
7144b50915 | |
|
|
0e8713e1eb | |
|
|
62a265d3c5 | |
|
|
59100d75e1 | |
|
|
b655c0a2b7 | |
|
|
6208cbbded | |
|
|
7c62cf8254 | |
|
|
c61f01783a | |
|
|
ce15e71dd8 | |
|
|
c6ea154309 | |
|
|
2a9bcb15e0 | |
|
|
53a9833a3c | |
|
|
71d5c081e8 | |
|
|
81d57c271b | |
|
|
65524de79a | |
|
|
45fbb1ebc8 | |
|
|
7a68675fc6 | |
|
|
25ddfaaab0 | |
|
|
98f1f2f465 | |
|
|
cf09b2e34d | |
|
|
1cea7b72e3 | |
|
|
50a68fe8cc | |
|
|
6f0c54caa4 | |
|
|
590434e55f | |
|
|
545755c2b7 | |
|
|
0a34a87495 | |
|
|
252593b934 | |
|
|
43bcc961a2 | |
|
|
f8bb0da47b | |
|
|
1d4535ad23 | |
|
|
baadb61681 | |
|
|
41b612d150 | |
|
|
6e784e4ca3 | |
|
|
b977791f50 | |
|
|
4672a6fd52 | |
|
|
d0836be06f | |
|
|
c7d79d86a9 | |
|
|
9bc0152371 | |
|
|
21af69f3eb | |
|
|
55357d2270 | |
|
|
66aed4dfb1 | |
|
|
ccbd8f8c96 | |
|
|
7836be3be5 | |
|
|
c2e02170bb | |
|
|
e240abe9b1 | |
|
|
eaa9fae39d | |
|
|
a42ad1f4f7 | |
|
|
e0448ad699 | |
|
|
cc8e690ee8 | |
|
|
4083b3dd0f | |
|
|
1754a89208 | |
|
|
d6c2ddbe89 | |
|
|
551283ba4c | |
|
|
c0bacabab2 | |
|
|
2d3e9f7d2b | |
|
|
e6d5d12c03 | |
|
|
5958599ca9 | |
|
|
66dda1a323 | |
|
|
280129046e | |
|
|
cf4d011ac0 | |
|
|
8d5df5a41c | |
|
|
fc66b1fc68 | |
|
|
316e59084d | |
|
|
7483a11dd6 | |
|
|
47e751d63c | |
|
|
fb1929011f | |
|
|
5b3e70a353 | |
|
|
19d037f11a | |
|
|
75f6c0b2f9 | |
|
|
5a0eba57e5 | |
|
|
3321b220b8 | |
|
|
b682787a2e | |
|
|
252fbffede | |
|
|
8601beed76 | |
|
|
8571f5d7f2 | |
|
|
62d6497f6a | |
|
|
b5446d67bb | |
|
|
8f602c309a | |
|
|
04f3d418d1 | |
|
|
8859a8a019 | |
|
|
0ae15e3981 | |
|
|
c233c86457 | |
|
|
e74699276b | |
|
|
65eacb35a8 | |
|
|
3e0016d8d1 | |
|
|
601405b76f | |
|
|
10d78b04d6 | |
|
|
7547d1c871 | |
|
|
45b177c2d2 | |
|
|
730ee35665 | |
|
|
3afcb8e8c4 | |
|
|
8a83b1bd34 | |
|
|
4cd41f799d | |
|
|
9558b2103e | |
|
|
a1683d9323 | |
|
|
da6b46d8d7 | |
|
|
092d527971 | |
|
|
153a6cabda | |
|
|
494bd9aee9 | |
|
|
1600611850 | |
|
|
b56a878bc2 | |
|
|
865c88e340 | |
|
|
91eb61c3c9 | |
|
|
63ac275a5f | |
|
|
ccce832b8f | |
|
|
b38727956d | |
|
|
0b1d536e04 | |
|
|
6359e55d52 | |
|
|
4c1b6832f6 | |
|
|
a9d4187fad | |
|
|
03c37619d5 | |
|
|
6a09a76bb6 | |
|
|
4a11208ae4 | |
|
|
65009d8e62 | |
|
|
2f1ccdddae | |
|
|
a739d541a5 | |
|
|
76cc29cb47 | |
|
|
230573ab10 | |
|
|
b0e3ad34f4 | |
|
|
a0319ce725 | |
|
|
78b1f19a64 | |
|
|
2d3c03622e | |
|
|
6719babbce | |
|
|
17528421bf | |
|
|
6ec50c7b47 | |
|
|
ce640dbce2 | |
|
|
fbadf47724 | |
|
|
d779d080e4 | |
|
|
ec75e2b0f3 | |
|
|
d03c5fe016 | |
|
|
9213667ba2 | |
|
|
8ee427d6bb | |
|
|
ed1ffb325a | |
|
|
fdf496daf2 | |
|
|
7fbe973ad9 | |
|
|
13736433b1 | |
|
|
c81f6cfdbd | |
|
|
7202302537 | |
|
|
6eaeb0f6af | |
|
|
a9f84d58b3 | |
|
|
c1c8d21bc4 | |
|
|
854d6fbf79 | |
|
|
a35c1d331d | |
|
|
ea8da7fedd | |
|
|
7e6e3d1f24 | |
|
|
176e067fb9 | |
|
|
1238dbcb0b | |
|
|
1df318d08a | |
|
|
315a95824b | |
|
|
21c1be85ab | |
|
|
7af8f7e2f4 | |
|
|
50eec4afd6 | |
|
|
1cd31dc9bb | |
|
|
3a06ff0b19 | |
|
|
f9b0656ad8 | |
|
|
01340b2bcf | |
|
|
9ce38e487b | |
|
|
a73b744853 | |
|
|
cebdf810d6 | |
|
|
21be0bccef | |
|
|
df48717c87 | |
|
|
334ef9a266 | |
|
|
a0030b6e6a | |
|
|
e108a279c7 | |
|
|
5f45225565 | |
|
|
efeb3665c1 | |
|
|
456e8a8841 | |
|
|
383f008a05 | |
|
|
6f1583fb01 | |
|
|
69338e78f3 | |
|
|
f0674e9648 | |
|
|
3c4b29b061 | |
|
|
fa20cc51be | |
|
|
258caf4a61 | |
|
|
b67dabb03d | |
|
|
e2f0fca4ad | |
|
|
1d4daa1c53 | |
|
|
8c2ee1378e | |
|
|
877817a5a3 | |
|
|
8eea071d3e | |
|
|
11d5b0bd8d | |
|
|
caa81d7368 | |
|
|
2dc0cd2b32 | |
|
|
ba8506c47b | |
|
|
947654aa64 | |
|
|
9df53fb968 | |
|
|
c87ac7bb29 | |
|
|
a1c763e6e1 | |
|
|
5f6f92a8d1 | |
|
|
bb1ca6886a | |
|
|
975a9a1e7e | |
|
|
3e2381ea69 | |
|
|
edb09d7ffa | |
|
|
f91024f676 | |
|
|
28e07908a2 | |
|
|
6a61c433ee | |
|
|
50e1c635d5 | |
|
|
36e39dd0cf | |
|
|
666533989a | |
|
|
39e3b81e5e | |
|
|
3f4d3d91f3 | |
|
|
81b95ab868 | |
|
|
2c914492fd | |
|
|
ff4a3a438e | |
|
|
15e1e7704b | |
|
|
6a06d84243 | |
|
|
a9caf3ee3c | |
|
|
280335bf14 | |
|
|
f9c4dcd1dd | |
|
|
dd2bb115b0 | |
|
|
d7786eafa7 | |
|
|
684dfca280 | |
|
|
05486b909a | |
|
|
86e45d7728 | |
|
|
b4b2f6fef7 | |
|
|
49831a3f06 | |
|
|
49356a792a | |
|
|
3d01cc2ca3 | |
|
|
61220a8b42 | |
|
|
be3007c6cd | |
|
|
9e9a64bcb6 | |
|
|
854ce8aa7d | |
|
|
7b753d69b0 | |
|
|
5c586f1192 | |
|
|
17e73cee3a | |
|
|
990b508703 | |
|
|
cb4ac02d7b | |
|
|
92d20a66be | |
|
|
6f23d94201 | |
|
|
ba62fdc694 | |
|
|
0ef8cb4721 | |
|
|
d0dad8aa38 | |
|
|
5c0f12afae | |
|
|
5fb5ecb98a | |
|
|
a405c8db97 | |
|
|
82aca890f0 | |
|
|
ade6380f1a | |
|
|
44371046e0 | |
|
|
3c927fa7ed | |
|
|
2d1d948c5e | |
|
|
c34960912a | |
|
|
3e5110501c | |
|
|
57a06aaa2c | |
|
|
61e879fa32 | |
|
|
d8b223e379 | |
|
|
e2c29c81df | |
|
|
76ee1112e5 | |
|
|
715b591185 | |
|
|
2ac2e807ea | |
|
|
306d8fd23d | |
|
|
27358d395c | |
|
|
9a3f1f4928 | |
|
|
4a1d5194fe | |
|
|
7c56fe22eb | |
|
|
043e9f2d6d | |
|
|
e00d9a145b | |
|
|
11bc6c56e3 | |
|
|
fd5c84fabc | |
|
|
1f49dffdf3 | |
|
|
78a2bf7352 | |
|
|
a04a1f31cf | |
|
|
340b820478 | |
|
|
33dc750730 | |
|
|
8756e69497 | |
|
|
233803688a | |
|
|
0c1d72b602 | |
|
|
a4010572cb | |
|
|
b726801a9b | |
|
|
80b7d224e8 | |
|
|
0ae60630b5 | |
|
|
112271b8f6 | |
|
|
93e9f097a1 | |
|
|
6f217bbf63 | |
|
|
0d0f187b14 | |
|
|
c025afe536 | |
|
|
32532107f5 | |
|
|
e757c41a57 | |
|
|
78c10ee651 | |
|
|
178e836f71 | |
|
|
4ed24489fa | |
|
|
8a5c449bd8 | |
|
|
b266bb2937 | |
|
|
b0b57b9f9b | |
|
|
a98bd22216 | |
|
|
587ec03af7 | |
|
|
7c3d35596f | |
|
|
9df5d4fe91 | |
|
|
a09d788310 | |
|
|
b99ad9f80f | |
|
|
fe440ce9cd | |
|
|
206449b674 | |
|
|
173b06ad88 | |
|
|
999539196e | |
|
|
9439356727 | |
|
|
96783aab43 | |
|
|
e0a6d06fc0 | |
|
|
acc915075b | |
|
|
d5074263f8 | |
|
|
b05e7fe90d | |
|
|
a5eb9ce00c | |
|
|
fde8ca480c | |
|
|
7533fde765 | |
|
|
83b88c502a | |
|
|
a5357c8d49 | |
|
|
f9c1d25113 | |
|
|
4faf891b8a | |
|
|
890fc5b0e6 | |
|
|
d3f50a9185 | |
|
|
365edc7c32 | |
|
|
669c550ab8 | |
|
|
68c7c99adf | |
|
|
c243bc6476 | |
|
|
abad55509a | |
|
|
e52fb5ae15 | |
|
|
d9690a131e | |
|
|
029eab1569 | |
|
|
4d4ebb395e | |
|
|
c7b2218283 | |
|
|
1f3b8726d1 | |
|
|
8c51d8ea7c | |
|
|
8705978bb7 | |
|
|
1cb6b26288 | |
|
|
875442057f | |
|
|
905443f39f | |
|
|
abe7a7835c | |
|
|
5ddfa9c6b3 | |
|
|
e2dc9174e8 | |
|
|
08f378764a | |
|
|
51be1dfe0b | |
|
|
a9b3d222c4 | |
|
|
f7c0d367dc | |
|
|
6b65bbd86b | |
|
|
91a30c8967 | |
|
|
379d96b304 | |
|
|
9928d80daf | |
|
|
458525e2e1 | |
|
|
603ae2cb22 | |
|
|
a822fd7615 | |
|
|
fc7bf4dee4 | |
|
|
7092ce68af | |
|
|
acf62ef1cf |
|
|
@ -0,0 +1,2 @@
|
|||
tidelift: maven/org.slf4j:slf4j-api
|
||||
github: qos-ch
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
|
||||
|
||||
concurrency:
|
||||
# On master/release, we don't want any jobs cancelled so the sha is used to name the group
|
||||
# On PR branches, we cancel the job if new commits are pushed
|
||||
# More info: https://stackoverflow.com/a/68422069/253468
|
||||
group: ${{ (github.ref == 'refs/heads/branch_1.2.18' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' ) && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
Test:
|
||||
name: JDK ${{ matrix.jdk }}, ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
jdk: [11, 17, 19]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
fail-fast: true
|
||||
max-parallel: 4
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 50
|
||||
- name: Set up Java ${{ matrix.jdk }}
|
||||
if: ${{ matrix.jdk != '8' }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: ${{ matrix.jdk }}
|
||||
- name: Install
|
||||
# download dependencies, etc, so test log looks better
|
||||
run: mvn -B install
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF8"?>
|
||||
<toolchains>
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
<version>1.8</version>
|
||||
</provides>
|
||||
<configuration>
|
||||
<jdkHome>${env.JAVA_HOME_8}</jdkHome>
|
||||
</configuration>
|
||||
</toolchain>
|
||||
</toolchains>
|
||||
|
|
@ -31,8 +31,8 @@
|
|||
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
|
||||
<option name="KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE" value="true" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
|
|
|
|||
16
.travis.yml
16
.travis.yml
|
|
@ -1,7 +1,21 @@
|
|||
dist: trusty
|
||||
|
||||
language: java
|
||||
|
||||
jdk:
|
||||
- oraclejdk9
|
||||
- oraclejdk11
|
||||
|
||||
notifications:
|
||||
email:
|
||||
- notification@qos.ch
|
||||
|
||||
install: /bin/true
|
||||
|
||||
script:
|
||||
- mvn clean
|
||||
- mvn install
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
github: qos-ch
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2017 QOS.ch
|
||||
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
|
|
|||
73
README.md
73
README.md
|
|
@ -1,14 +1,69 @@
|
|||
# About SLF4J
|
||||
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.
|
||||
|
||||
The Simple Logging Facade for Java (SLF4J) serves as a simple facade
|
||||
or abstraction for various logging frameworks (e.g. java.util.logging,
|
||||
logback, reload4j, log4j 2.x, logevents, penna, rainbowgum, tinylog)
|
||||
allowing the end user to plug in the desired logging framework at
|
||||
deployment time.
|
||||
|
||||
More information can be found on the [SLF4J website](http://www.slf4j.org).
|
||||
# Build Status
|
||||
[](https://travis-ci.org/qos-ch/slf4j)
|
||||
|
||||
# Search org.slf4j artifacts on Maven Central
|
||||
[](https://central.sonatype.com/search?namespace=org.slf4j)
|
||||
|
||||
|
||||
# In case of problems
|
||||
|
||||
In case of problems please do not hesitate to post an e-mail message
|
||||
on the [slf4j-user@qos.ch](https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-user)
|
||||
mailing list or to start a <a
|
||||
href="https://github.com/qos-ch/slf4j/discussions">discussion</a> on
|
||||
github. However, please do not directly e-mail SLF4J developers. The
|
||||
answer to your question might be useful to other users. Moreover,
|
||||
there are many knowledgeable users on the slf4j-user mailing lists who
|
||||
can quickly answer your questions.
|
||||
|
||||
# Urgent issues
|
||||
|
||||
For urgent issues do not hesitate to [champion a
|
||||
release](https://github.com/sponsors/qos-ch/sponsorships?tier_id=77436).
|
||||
In principle, most championed issues are solved within 3 business days
|
||||
ensued by a release.
|
||||
|
||||
# How to build SLF4J
|
||||
|
||||
SLF4J uses Maven as its build tool.
|
||||
|
||||
SLF4J version 2.0.x will run under Java 8 but requires Java 9 or later to build.
|
||||
|
||||
# How to contribute pull requests
|
||||
If you are interested in improving SLF4J, great! The SLF4J community looks forward to your contribution. Please follow this process:
|
||||
|
||||
1. Start a discussion on the [slf4j-dev mailing list](http://www.slf4j.org/mailing-lists.html) about your proposed change. Alternately file a [bug report](http://www.slf4j.org/bug-reporting.html).
|
||||
2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for your contribution to make it easier to merge your changes back.
|
||||
3. Make your changes on the branch you hopefuly created in Step 2. Be sure that your code passes existing unit tests. Please add unit tests for your work if appropriate. It usually is.
|
||||
4. Push your changes to your fork/branch in github. Don't push it to your master! If you do it will make it harder to submit new changes later.
|
||||
5. Submit a pull request to SLF4J from from your commit page on github.
|
||||
If you are interested in improving SLF4J, that is great! The SLF4J
|
||||
community looks forward to your contribution. Please follow this
|
||||
process:
|
||||
|
||||
1. Start a discussion on the [slf4j-dev mailing
|
||||
list](http://www.slf4j.org/mailing-lists.html) about your proposed
|
||||
change. Alternately, file a [bug
|
||||
report](https://github.com/qos-ch/slf4j/issues) on github to initiate the
|
||||
discussion.
|
||||
|
||||
2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for
|
||||
your contribution to make it easier to merge your changes back.
|
||||
|
||||
3. Make your changes on the branch created in Step 2. Be
|
||||
sure that your code passes existing unit tests. Please add unit tests
|
||||
for your work if appropriate. It usually is.
|
||||
|
||||
4. All commits must have signed off by the contributor attesting to
|
||||
[Developer Certificate of Origin
|
||||
(DCO)](https://developercertificate.org/). Commits without sign off
|
||||
will be automatically rejected by the [DCO GitHub
|
||||
check](https://probot.github.io/apps/dco/) application.
|
||||
|
||||
5. Push your changes to your fork/branch in GitHub. Don't push it to
|
||||
your master! If you do, it will make it harder to submit new changes
|
||||
later.
|
||||
|
||||
6. Submit a pull request to SLF4J from your commit page on GitHub.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
## Reporting security issues
|
||||
|
||||
Please report security issues related to the SLF4J project to the
|
||||
following email address:
|
||||
|
||||
support(at)qos.ch
|
||||
|
||||
|
||||
|
||||
|
||||
## Verifying contents
|
||||
|
||||
All SLF4J project artifacts published on Maven central are signed. For
|
||||
each artifact, there is an associated signature file with the .asc
|
||||
suffix.
|
||||
|
||||
### After 2022-08-08
|
||||
|
||||
To verify the signature use [this public key](https://www.slf4j.org/public-keys/60200AC4AE761F1614D6C46766D68DAA073BE985.gpg). Here is its fingerprint:
|
||||
```
|
||||
pub nistp521 2022-08-08 [SC]
|
||||
60200AC4AE761F1614D6C46766D68DAA073BE985
|
||||
uid Ceki Gulcu <ceki@qos.ch>
|
||||
sub nistp521 2022-08-08 [E]
|
||||
```
|
||||
|
||||
A copy of this key is stored on the
|
||||
[keys.openpgp.org](https://keys.openpgp.org) keyserver. To add it to
|
||||
your public key ring use the following command:
|
||||
|
||||
```
|
||||
> FINGER_PRINT=60200AC4AE761F1614D6C46766D68DAA073BE985
|
||||
> gpg --keyserver hkps://keys.openpgp.org --recv-keys $FINGER_PRINT
|
||||
```
|
||||
|
||||
### Before 2022-08-08
|
||||
|
||||
To verify the signature use [this public key](https://www.slf4j.org/public-keys/ceki-public-key.pgp). Here is its fingerprint:
|
||||
|
||||
```
|
||||
pub 2048R/A511E325 2012-04-26
|
||||
Key fingerprint = 475F 3B8E 59E6 E63A A780 6748 2C7B 12F2 A511 E325
|
||||
uid Ceki Gulcu <ceki@qos.ch>
|
||||
sub 2048R/7FBFA159 2012-04-26
|
||||
```
|
||||
|
||||
A copy of this key is stored on the
|
||||
[keys.openpgp.org](https://keys.openpgp.org) keyserver. To add it to
|
||||
your public key ring use the following command:
|
||||
|
||||
```
|
||||
> FINGER_PRINT=475F3B8E59E6E63AA78067482C7B12F2A511E325
|
||||
> gpg --keyserver hkps://keys.openpgp.org --recv-keys $FINGER_PRINT
|
||||
```
|
||||
|
||||
|
||||
## Preventing commit history overwrite
|
||||
|
||||
In order to prevent loss of commit history, developers of the project
|
||||
are highly encouraged to deny branch deletions or history overwrites
|
||||
by invoking the following two commands on their local copy of the
|
||||
repository.
|
||||
|
||||
|
||||
```
|
||||
git config receive.denyDelete true
|
||||
git config receive.denyNonFastForwards true
|
||||
```
|
||||
|
|
@ -82,12 +82,12 @@
|
|||
</target>
|
||||
|
||||
<target name="testAll" depends="init,
|
||||
testNoProvider150,
|
||||
testNoProvider150,
|
||||
testMismatch,
|
||||
testMatch,
|
||||
testMultiBinding,
|
||||
testFuture_16Series,
|
||||
testActiveSecurityManager">
|
||||
testMultiBinding,
|
||||
testFuture_16Series"
|
||||
>
|
||||
</target>
|
||||
|
||||
|
||||
|
|
@ -201,7 +201,7 @@
|
|||
<property name="path_to_policy" value="file:./src/policy/java-under-ant.policy"/>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- no longer supported in JDK 24 and later -->
|
||||
<target name="testActiveSecurityManager" depends="setPathToPolicy_FromTop, setPathToPolicy_FromIntegration">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<jvmarg value="-Djava.security.manager"/>
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
|
||||
<!-- for some reason if mvn is invoked from the parent directory, junit gets
|
||||
invoked from the parent dir, which messes up theses tests. Hence, the
|
||||
invoked from the parent dir, which messes up these tests. Hence, the
|
||||
fork="yes" dir="${basedir}" -->
|
||||
|
||||
<!--
|
||||
|
|
@ -107,4 +107,4 @@
|
|||
</junit>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>integration</artifactId>
|
||||
|
|
@ -124,9 +125,19 @@
|
|||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ Implementation-Title: iBundle
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: iBundle
|
||||
Bundle-Name: abundle
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: apack
|
||||
Import-Package: org.osgi.framework, org.slf4j;version=1.5
|
||||
|
|
@ -27,6 +27,7 @@ package org.slf4j;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.slf4j.helpers.Reporter.SLF4J_INTERNAL_VERBOSITY_KEY;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
|
@ -41,14 +42,15 @@ public class CompatibilityAssertionTest {
|
|||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty(SLF4J_INTERNAL_VERBOSITY_KEY, "debug");
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
System.clearProperty(SLF4J_INTERNAL_VERBOSITY_KEY);
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +59,13 @@ public class CompatibilityAssertionTest {
|
|||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
assertEquals(1, sps.stringList.size());
|
||||
assertEquals(2, sps.stringList.size());
|
||||
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.contains(msg));
|
||||
|
||||
assertTrue(s0.startsWith("SLF4J(D): Connected with provider of type [org.slf4j.simple.SimpleServiceProvider]"));
|
||||
|
||||
String s1 = (String) sps.stringList.get(1);
|
||||
assertTrue(s1.contains(msg));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,28 +39,29 @@ public class MultiBindingAssertionTest {
|
|||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
List<String> list = sps.stringList;
|
||||
assertMsgContains(list, 0, "Class path contains multiple SLF4J providers.");
|
||||
assertMsgContains(list, 1, "Found provider");
|
||||
assertMsgContains(list, 2, "Found provider");
|
||||
assertMsgContains(list, 3, "See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
|
||||
assertMsgContains(list, 4, "Actual provider is of type [");
|
||||
int line = 0;
|
||||
|
||||
assertMsgContains(list, line++, "Class path contains multiple SLF4J providers.");
|
||||
assertMsgContains(list, line++, "Found provider");
|
||||
assertMsgContains(list, line++, "Found provider");
|
||||
assertMsgContains(list, line++, "See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
|
||||
//assertMsgContains(list, line++, "SLF4J(D): Connected with provider of type [");
|
||||
}
|
||||
|
||||
void assertMsgContains(List<String> strList, int index, String msg) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class NoProviderAssertionTest {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public class OldAPIVersionMismatchAssertionTest {
|
|||
System.setErr(sps);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
System.setErr(old);
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ public class OutputVerifier {
|
|||
}
|
||||
{
|
||||
String s = (String) sps.stringList.get(2);
|
||||
assertTrue(s.contains("SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details."));
|
||||
assertTrue(s.contains("See https://www.slf4j.org/codes.html#noProviders for further details."));
|
||||
}
|
||||
|
||||
{
|
||||
String s = (String) sps.stringList.get(3);
|
||||
assertTrue(s.contains("SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8."));
|
||||
assertTrue(s.contains("Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier."));
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -42,7 +42,7 @@ public class OutputVerifier {
|
|||
}
|
||||
{
|
||||
String s = (String) sps.stringList.get(5);
|
||||
assertTrue(s.contains("See http://www.slf4j.org/codes.html#ignoredBindings for an explanation"));
|
||||
assertTrue(s.contains("See https://www.slf4j.org/codes.html#ignoredBindings for an explanation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ public class StringPrintStream extends PrintStream {
|
|||
|
||||
public static final String LINE_SEP = System.getProperty("line.separator");
|
||||
PrintStream other;
|
||||
List<String> stringList = new ArrayList<String>();
|
||||
List<String> stringList = new ArrayList<>();
|
||||
|
||||
public StringPrintStream(PrintStream ps) {
|
||||
super(ps);
|
||||
other = ps;
|
||||
}
|
||||
|
||||
|
||||
public void print(String s) {
|
||||
other.print(s);
|
||||
stringList.add(s);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import junit.framework.TestCase;
|
|||
|
||||
public class Issue324Test extends TestCase {
|
||||
|
||||
public void testLoggerCreationInPresenseOfSecurityManager() {
|
||||
public void testLoggerCreationInPresenceOfSecurityManager() {
|
||||
String currentDir = System.getProperty("user.dir");
|
||||
System.out.println("currentDir:" + currentDir);
|
||||
Logger logger = LoggerFactory.getLogger(Issue324Test.class);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.osgi.framework.BundleListener;
|
|||
|
||||
public class CheckingBundleListener implements BundleListener {
|
||||
|
||||
List<BundleEvent> eventList = new ArrayList<BundleEvent>();
|
||||
List<BundleEvent> eventList = new ArrayList<>();
|
||||
|
||||
public void bundleChanged(BundleEvent be) {
|
||||
eventList.add(be);
|
||||
|
|
@ -45,16 +45,14 @@ public class CheckingBundleListener implements BundleListener {
|
|||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
for (BundleEvent fe : eventList) {
|
||||
dump(fe);
|
||||
}
|
||||
}
|
||||
|
||||
boolean exists(String bundleName) {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
Bundle b = fe.getBundle();
|
||||
for (BundleEvent bundleEvent : eventList) {
|
||||
Bundle b = bundleEvent.getBundle();
|
||||
System.out.println("===[" + b + "]");
|
||||
if (bundleName.equals(b.getSymbolicName())) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class FelixHost {
|
|||
try {
|
||||
// Create host activator;
|
||||
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
// list.add(new HostActivator());
|
||||
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ import org.osgi.framework.FrameworkListener;
|
|||
|
||||
public class FrameworkErrorListener implements FrameworkListener {
|
||||
|
||||
public List<FrameworkEvent> errorList = new ArrayList<FrameworkEvent>();
|
||||
public List<FrameworkEvent> errorList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void frameworkEvent(FrameworkEvent fe) {
|
||||
if (fe.getType() == FrameworkEvent.ERROR) {
|
||||
errorList.add(fe);
|
||||
|
|
@ -54,9 +55,8 @@ public class FrameworkErrorListener implements FrameworkListener {
|
|||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for (int i = 0; i < errorList.size(); i++) {
|
||||
FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
|
||||
dump(fe);
|
||||
for (FrameworkEvent frameworkEvent : errorList) {
|
||||
dump(frameworkEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
|
@ -16,10 +17,18 @@
|
|||
<description>JCL 1.2 implemented over SLF4J</description>
|
||||
<url>http://www.slf4j.org</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache-2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<properties>
|
||||
<module-name>org.apache.commons.logging</module-name>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
@ -31,5 +40,19 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<_exportcontents>org.apache.commons.logging*;version=${jcl.version};-noimport:=true</_exportcontents>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.commons.logging;
|
|||
* <p>A simple logging interface abstracting logging APIs. In order to be
|
||||
* instantiated successfully by {@link LogFactory}, classes that implement
|
||||
* this interface must have a constructor that takes a single String
|
||||
* parameter representing the "name" of this Log.</p>
|
||||
* parameter representing the "name" of this Log.
|
||||
*
|
||||
* <p> The six logging levels used by <code>Log</code> are (in order):
|
||||
* <ol>
|
||||
|
|
@ -34,27 +34,27 @@ package org.apache.commons.logging;
|
|||
* The mapping of these log levels to the concepts used by the underlying
|
||||
* logging system is implementation dependent.
|
||||
* The implementation should ensure, though, that this ordering behaves
|
||||
* as expected.</p>
|
||||
* as expected.
|
||||
*
|
||||
* <p>Performance is often a logging concern.
|
||||
* By examining the appropriate property,
|
||||
* a component can avoid expensive operations (producing information
|
||||
* to be logged).</p>
|
||||
* to be logged).
|
||||
*
|
||||
* <p> For example,
|
||||
* <code><pre>
|
||||
* <pre>
|
||||
* if (log.isDebugEnabled()) {
|
||||
* ... do something expensive ...
|
||||
* log.debug(theResult);
|
||||
* }
|
||||
* </pre></code>
|
||||
* </p>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>Configuration of the underlying logging system will generally be done
|
||||
* external to the Logging APIs, through whatever mechanism is supported by
|
||||
* that system.</p>
|
||||
* that system.
|
||||
*
|
||||
* <p style="color: #E40; font-weight: bold;">Please note that this interface is identical to that found in JCL 1.1.1.</p>
|
||||
* <p style="color: #E40; font-weight: bold;">Please note that this interface is identical to that found in JCL 1.1.1.
|
||||
*
|
||||
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||
* @author Rod Waldhoff
|
||||
|
|
@ -65,74 +65,74 @@ public interface Log {
|
|||
// ----------------------------------------------------- Logging Properties
|
||||
|
||||
/**
|
||||
* <p> Is debug logging currently enabled? </p>
|
||||
* <p> Is debug logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than debug. </p>
|
||||
* when the log level is more than debug.
|
||||
*/
|
||||
public boolean isDebugEnabled();
|
||||
|
||||
/**
|
||||
* <p> Is error logging currently enabled? </p>
|
||||
* <p> Is error logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than error. </p>
|
||||
* when the log level is more than error.
|
||||
*/
|
||||
public boolean isErrorEnabled();
|
||||
|
||||
/**
|
||||
* <p> Is fatal logging currently enabled? </p>
|
||||
* <p> Is fatal logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than fatal. </p>
|
||||
* when the log level is more than fatal.
|
||||
*/
|
||||
public boolean isFatalEnabled();
|
||||
|
||||
/**
|
||||
* <p> Is info logging currently enabled? </p>
|
||||
* <p> Is info logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than info. </p>
|
||||
* when the log level is more than info.
|
||||
*
|
||||
* @return true if info enabled, false otherwise
|
||||
*/
|
||||
public boolean isInfoEnabled();
|
||||
|
||||
/**
|
||||
* <p> Is trace logging currently enabled? </p>
|
||||
* <p> Is trace logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than trace. </p>
|
||||
* when the log level is more than trace.
|
||||
*
|
||||
* @return true if trace enabled, false otherwise
|
||||
*/
|
||||
public boolean isTraceEnabled();
|
||||
|
||||
/**
|
||||
* <p> Is warn logging currently enabled? </p>
|
||||
* <p> Is warn logging currently enabled?
|
||||
*
|
||||
* <p> Call this method to prevent having to perform expensive operations
|
||||
* (for example, <code>String</code> concatenation)
|
||||
* when the log level is more than warn. </p>
|
||||
* when the log level is more than warn.
|
||||
*/
|
||||
public boolean isWarnEnabled();
|
||||
|
||||
// -------------------------------------------------------- Logging Methods
|
||||
|
||||
/**
|
||||
* <p> Log a message with trace log level. </p>
|
||||
* <p> Log a message with trace log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void trace(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with trace log level. </p>
|
||||
* <p> Log an error with trace log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
@ -140,14 +140,14 @@ public interface Log {
|
|||
public void trace(Object message, Throwable t);
|
||||
|
||||
/**
|
||||
* <p> Log a message with debug log level. </p>
|
||||
* <p> Log a message with debug log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void debug(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with debug log level. </p>
|
||||
* <p> Log an error with debug log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
@ -155,14 +155,14 @@ public interface Log {
|
|||
public void debug(Object message, Throwable t);
|
||||
|
||||
/**
|
||||
* <p> Log a message with info log level. </p>
|
||||
* <p> Log a message with info log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void info(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with info log level. </p>
|
||||
* <p> Log an error with info log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
@ -170,14 +170,14 @@ public interface Log {
|
|||
public void info(Object message, Throwable t);
|
||||
|
||||
/**
|
||||
* <p> Log a message with warn log level. </p>
|
||||
* <p> Log a message with warn log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void warn(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with warn log level. </p>
|
||||
* <p> Log an error with warn log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
@ -185,14 +185,14 @@ public interface Log {
|
|||
public void warn(Object message, Throwable t);
|
||||
|
||||
/**
|
||||
* <p> Log a message with error log level. </p>
|
||||
* <p> Log a message with error log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void error(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with error log level. </p>
|
||||
* <p> Log an error with error log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
@ -200,14 +200,14 @@ public interface Log {
|
|||
public void error(Object message, Throwable t);
|
||||
|
||||
/**
|
||||
* <p> Log a message with fatal log level. </p>
|
||||
* <p> Log a message with fatal log level.
|
||||
*
|
||||
* @param message log this message
|
||||
*/
|
||||
public void fatal(Object message);
|
||||
|
||||
/**
|
||||
* <p> Log an error with fatal log level. </p>
|
||||
* <p> Log an error with fatal log level.
|
||||
*
|
||||
* @param message log this message
|
||||
* @param t log this cause
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package org.apache.commons.logging;
|
|||
* An exception that is thrown only if a suitable <code>LogFactory</code> or
|
||||
* <code>Log</code> instance cannot be created by the corresponding factory
|
||||
* methods.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In this version of JCL, this exception will never be thrown in practice.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.apache.commons.logging.impl.SLF4JLogFactory;
|
|||
* Factory for creating {@link Log} instances, which always delegates to an
|
||||
* instance of {@link SLF4JLogFactory}.
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Craig R. McClanahan
|
||||
* @author Costin Manolache
|
||||
|
|
@ -170,7 +170,7 @@ public abstract class LogFactory {
|
|||
* <p>
|
||||
* Construct (if necessary) and return a <code>Log</code> instance, using
|
||||
* the factory's current set of configuration attributes.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <strong>NOTE </strong>- Depending upon the implementation of the
|
||||
|
|
@ -178,7 +178,7 @@ public abstract class LogFactory {
|
|||
* you are returned may or may not be local to the current application, and
|
||||
* may or may not be returned again on a subsequent call with the same name
|
||||
* argument.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* Logical name of the <code>Log</code> instance to be
|
||||
|
|
@ -229,7 +229,7 @@ public abstract class LogFactory {
|
|||
* Construct (if necessary) and return a <code>LogFactory</code> instance,
|
||||
* using the following ordered lookup procedure to determine the name of the
|
||||
* implementation class to be loaded.
|
||||
* </p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>The <code>org.apache.commons.logging.LogFactory</code> system
|
||||
* property.</li>
|
||||
|
|
@ -248,7 +248,7 @@ public abstract class LogFactory {
|
|||
* <code>LogFactory</code> implementation class is utilized, all of the
|
||||
* properties defined in this file will be set as configuration attributes on
|
||||
* the corresponding <code>LogFactory</code> instance.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @exception LogConfigurationException
|
||||
* if the implementation class is not available or cannot
|
||||
|
|
@ -345,64 +345,64 @@ public abstract class LogFactory {
|
|||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static Object createFactory(String factoryClass, ClassLoader classLoader) {
|
||||
throw new UnsupportedOperationException("Operation [factoryClass] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [factoryClass] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static ClassLoader directGetContextClassLoader() {
|
||||
throw new UnsupportedOperationException("Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static ClassLoader getContextClassLoader() throws LogConfigurationException {
|
||||
throw new UnsupportedOperationException("Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static ClassLoader getClassLoader(Class clazz) {
|
||||
throw new UnsupportedOperationException("Operation [getClassLoader] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [getClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static boolean isDiagnosticsEnabled() {
|
||||
throw new UnsupportedOperationException("Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static void logRawDiagnostic(String msg) {
|
||||
throw new UnsupportedOperationException("Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static LogFactory newFactory(final String factoryClass, final ClassLoader classLoader, final ClassLoader contextClassLoader) {
|
||||
throw new UnsupportedOperationException("Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists to ensure signature compatibility.
|
||||
*/
|
||||
protected static LogFactory newFactory(final String factoryClass, final ClassLoader classLoader) {
|
||||
throw new UnsupportedOperationException("Operation [newFactory] is not supported in jcl-over-slf4j. See also "
|
||||
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
throw new UnsupportedOperationException(
|
||||
"Operation [newFactory] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
|
|||
* <p>
|
||||
* Trivial implementation of Log that throws away all messages. No configurable
|
||||
* system properties are supported.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||
* @author Rod Waldhoff
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient LocationAwareLogger logger;
|
||||
private final transient LocationAwareLogger logger;
|
||||
|
||||
private static final String FQCN = SLF4JLocationAwareLog.class.getName();
|
||||
|
||||
|
|
@ -104,7 +104,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null, null);
|
||||
if (isTraceEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,7 +119,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null, t);
|
||||
if (isTraceEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +132,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null, null);
|
||||
if (isDebugEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,7 +147,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null, t);
|
||||
if (isDebugEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +160,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void info(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null, null);
|
||||
if (isInfoEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -165,7 +175,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null, t);
|
||||
if (isInfoEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -176,7 +188,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null, null);
|
||||
if (isWarnEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -189,7 +203,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null, t);
|
||||
if (isWarnEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -200,7 +216,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void error(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, null);
|
||||
if (isErrorEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -213,7 +231,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, t);
|
||||
if (isErrorEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -224,7 +244,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, null);
|
||||
if (isErrorEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -237,7 +259,9 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
|
|||
* the exception to log
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, t);
|
||||
if (isErrorEnabled()) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String.valueOf(message), null, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class SLF4JLog implements Log, Serializable {
|
|||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient Logger logger;
|
||||
private final transient Logger logger;
|
||||
|
||||
public SLF4JLog(Logger logger) {
|
||||
this.logger = logger;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||
*
|
||||
* <p>
|
||||
* This implementation ignores any configured attributes.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Rod Waldhoff
|
||||
* @author Craig R. McClanahan
|
||||
|
|
@ -64,7 +64,7 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
* Public no-arguments constructor required by the lookup mechanism.
|
||||
*/
|
||||
public SLF4JLogFactory() {
|
||||
loggerMap = new ConcurrentHashMap<String, Log>();
|
||||
loggerMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Manifest Constants
|
||||
|
|
@ -105,12 +105,12 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
@SuppressWarnings("unchecked")
|
||||
public String[] getAttributeNames() {
|
||||
|
||||
List<String> names = new ArrayList<String>();
|
||||
List<String> names = new ArrayList<>();
|
||||
Enumeration<String> keys = attributes.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
names.add((String) keys.nextElement());
|
||||
}
|
||||
String results[] = new String[names.size()];
|
||||
String[] results = new String[names.size()];
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = (String) names.get(i);
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
* <p>
|
||||
* Construct (if necessary) and return a <code>Log</code> instance, using
|
||||
* the factory's current set of configuration attributes.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* Logical name of the <code>Log</code> instance to be returned
|
||||
|
|
@ -173,12 +173,10 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
public void release() {
|
||||
// This method is never called by jcl-over-slf4j classes. However,
|
||||
// in certain deployment scenarios, in particular if jcl-over-slf4j.jar
|
||||
// is
|
||||
// in the the web-app class loader and the official commons-logging.jar is
|
||||
// deployed in some parent class loader (e.g. commons/lib), then it is
|
||||
// possible
|
||||
// for the parent class loader to mask the classes shipping in
|
||||
// jcl-over-slf4j.jar.
|
||||
// is in the web-app class loader and the official commons-logging.jar
|
||||
// is deployed in some parent class loader (e.g. commons/lib), then it
|
||||
// is possible for the parent class loader to mask the classes shipping
|
||||
// in jcl-over-slf4j.jar.
|
||||
System.out.println("WARN: The method " + SLF4JLogFactory.class + "#release() was invoked.");
|
||||
System.out.println("WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.");
|
||||
System.out.flush();
|
||||
|
|
@ -216,4 +214,4 @@ public class SLF4JLogFactory extends LogFactory {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.apache.commons.logging.LogConfigurationException;
|
|||
* Simple implementation of Log that sends all enabled log messages, for all
|
||||
* defined loggers, to System.err. The following system properties are supported
|
||||
* to configure the behavior of this logger:
|
||||
* </p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>org.apache.commons.logging.simplelog.defaultlog</code> - Default
|
||||
* logging detail level for all instances of SimpleLog. Must be one of ("trace",
|
||||
|
|
@ -67,7 +67,7 @@ import org.apache.commons.logging.LogConfigurationException;
|
|||
* this implementation also checks for a class loader resource named
|
||||
* <code>"simplelog.properties"</code>, and includes any matching definitions
|
||||
* from this resource (if it exists).
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||
* @author Rod Waldhoff
|
||||
|
|
@ -165,7 +165,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
} catch (java.io.IOException e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showLogName = getBooleanProperty(systemPrefix + "showlogname", showLogName);
|
||||
|
|
@ -248,7 +248,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Set logging level.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param currentLogLevel
|
||||
* new logging level
|
||||
|
|
@ -262,7 +262,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Get logging level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public int getLevel() {
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
* <p>
|
||||
* Do the actual logging. This method assembles the message and then calls
|
||||
* <code>write()</code> to cause it to be written.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* One of the LOG_LEVEL_XXX constants defining the log level
|
||||
|
|
@ -354,7 +354,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
* Write the content of the message accumulated in the specified
|
||||
* <code>StringBuffer</code> to the appropriate output destination. The
|
||||
* default implementation writes to <code>System.err</code>.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param buffer
|
||||
* A <code>StringBuffer</code> containing the accumulated text to be
|
||||
|
|
@ -383,7 +383,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with debug log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void debug(Object message) {
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with debug log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void debug(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with trace log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void trace(Object message) {
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with trace log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void trace(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with info log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void info(Object message) {
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with info log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void info(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -455,7 +455,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with warn log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void warn(Object message) {
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with warn log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void warn(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with error log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void error(Object message) {
|
||||
|
||||
|
|
@ -491,7 +491,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with error log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void error(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -503,7 +503,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log a message with fatal log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void fatal(Object message) {
|
||||
|
||||
|
|
@ -515,7 +515,7 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Log an error with fatal log level.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final void fatal(Object message, Throwable t) {
|
||||
|
||||
|
|
@ -527,12 +527,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are debug messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isDebugEnabled() {
|
||||
|
||||
|
|
@ -542,12 +542,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are error messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isErrorEnabled() {
|
||||
|
||||
|
|
@ -557,12 +557,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are fatal messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isFatalEnabled() {
|
||||
|
||||
|
|
@ -572,12 +572,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are info messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isInfoEnabled() {
|
||||
|
||||
|
|
@ -587,12 +587,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are trace messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isTraceEnabled() {
|
||||
|
||||
|
|
@ -602,12 +602,12 @@ public class SimpleLog implements Log, Serializable {
|
|||
/**
|
||||
* <p>
|
||||
* Are warn messages currently enabled?
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This allows expensive operations such as <code>String</code> concatenation
|
||||
* to be avoided when the message will be ignored by the logger.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final boolean isWarnEnabled() {
|
||||
|
||||
|
|
@ -673,15 +673,13 @@ public class SimpleLog implements Log, Serializable {
|
|||
}
|
||||
|
||||
private static InputStream getResourceAsStream(final String name) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||
public InputStream run() {
|
||||
ClassLoader threadCL = getContextClassLoader();
|
||||
return AccessController.doPrivileged((PrivilegedAction<InputStream>) () -> {
|
||||
ClassLoader threadCL = getContextClassLoader();
|
||||
|
||||
if (threadCL != null) {
|
||||
return threadCL.getResourceAsStream(name);
|
||||
} else {
|
||||
return ClassLoader.getSystemResourceAsStream(name);
|
||||
}
|
||||
if (threadCL != null) {
|
||||
return threadCL.getResourceAsStream(name);
|
||||
} else {
|
||||
return ClassLoader.getSystemResourceAsStream(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ replacement for the original JCL version 1.0.4.
|
|||
<p>As the original JCL version 1.0.4, the present version supports
|
||||
various logging APIs. It differs from the original in implementation
|
||||
but not the public API. This implementation uses SLF4J under the
|
||||
covers. As as such, all the logging systems that SLF4J supports,
|
||||
covers. As such, all the logging systems that SLF4J supports,
|
||||
e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL.
|
||||
</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
Implementation-Title: jcl-over-slf4j
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: jcl.over.slf4j
|
||||
Bundle-Name: jcl-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Export-Package: org.apache.commons.logging;version=1.2,
|
||||
org.apache.commons.logging.impl;version=1.2
|
||||
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}
|
||||
|
|
@ -27,6 +27,7 @@ package org.apache.commons.logging.test;
|
|||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
@ -88,4 +89,58 @@ public class InvokeJCLTest {
|
|||
log.fatal(null, e);
|
||||
log.fatal("fatal message", e);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvoidConvertingObjectToString() {
|
||||
Log log = LogFactory.getLog(InvokeJCLTest.class);
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
TestMessage fatalMsg = new TestMessage("fatal msg");
|
||||
TestMessage errorMsg = new TestMessage("error msg");
|
||||
TestMessage warnMsg = new TestMessage("warn msg");
|
||||
TestMessage infoMsg = new TestMessage("info msg");
|
||||
TestMessage debugMsg = new TestMessage("debug msg");
|
||||
TestMessage traceMsg = new TestMessage("trace msg");
|
||||
|
||||
log.fatal(fatalMsg);
|
||||
log.fatal(fatalMsg, e);
|
||||
assertEquals(2, fatalMsg.invokedCount);
|
||||
|
||||
log.error(errorMsg);
|
||||
log.error(errorMsg, e);
|
||||
assertEquals(2, errorMsg.invokedCount);
|
||||
|
||||
log.warn(warnMsg);
|
||||
log.warn(warnMsg, e);
|
||||
assertEquals(2, warnMsg.invokedCount);
|
||||
|
||||
log.info(infoMsg);
|
||||
log.info(infoMsg, e);
|
||||
assertEquals(2, infoMsg.invokedCount);
|
||||
|
||||
log.debug(debugMsg);
|
||||
log.debug(debugMsg, e);
|
||||
assertEquals(0, debugMsg.invokedCount);
|
||||
|
||||
log.trace(traceMsg);
|
||||
log.trace(traceMsg, e);
|
||||
assertEquals(0, traceMsg.invokedCount);
|
||||
}
|
||||
|
||||
static class TestMessage {
|
||||
|
||||
private final String msg;
|
||||
int invokedCount = 0;
|
||||
|
||||
TestMessage(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
invokedCount++;
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2007 QOS.ch
|
||||
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
|
|
@ -25,10 +26,15 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
<build>
|
||||
<plugins>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
// Based on http://jira.qos.ch/browse/SLF4J-30
|
||||
|
||||
/**
|
||||
* <p>Bridge/route all JUL log records to the SLF4J API.</p>
|
||||
* <p>Bridge/route all JUL log records to the SLF4J API.
|
||||
* <p>Essentially, the idea is to install on the root logger an instance of
|
||||
* <code>SLF4JBridgeHandler</code> as the sole JUL handler in the system. Subsequently, the
|
||||
* SLF4JBridgeHandler instance will redirect all JUL log records are redirected
|
||||
* to the SLF4J API based on the following mapping of levels:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* FINEST -> TRACE
|
||||
* FINER -> DEBUG
|
||||
|
|
@ -52,7 +52,7 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
* INFO -> INFO
|
||||
* WARNING -> WARN
|
||||
* SEVERE -> ERROR</pre>
|
||||
* <p><b>Programmatic installation:</b></p>
|
||||
* <p><b>Programmatic installation:</b>
|
||||
* <pre>
|
||||
* // Optionally remove existing handlers attached to j.u.l root logger
|
||||
* SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5)
|
||||
|
|
@ -60,12 +60,12 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
* // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
|
||||
* // the initialization phase of your application
|
||||
* SLF4JBridgeHandler.install();</pre>
|
||||
* <p><b>Installation via <em>logging.properties</em> configuration file:</b></p>
|
||||
* <p><b>Installation via <em>logging.properties</em> configuration file:</b>
|
||||
* <pre>
|
||||
* // register SLF4JBridgeHandler as handler for the j.u.l. root logger
|
||||
* handlers = org.slf4j.bridge.SLF4JBridgeHandler</pre>
|
||||
* <p>Once SLF4JBridgeHandler is installed, logging by j.u.l. loggers will be directed to
|
||||
* SLF4J. Example: </p>
|
||||
* SLF4J. Example:
|
||||
* <pre>
|
||||
* import java.util.logging.Logger;
|
||||
* ...
|
||||
|
|
@ -79,12 +79,12 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
* SLF4J translation can seriously increase the cost of disabled logging
|
||||
* statements (60 fold or 6000% increase) and measurably impact the performance of enabled log
|
||||
* statements (20% overall increase).</b> Please note that as of logback-version 0.9.25,
|
||||
* it is possible to completely eliminate the 60 fold translation overhead for disabled
|
||||
* it is possible to completely eliminate the 60-fold translation overhead for disabled
|
||||
* log statements with the help of <a href="http://logback.qos.ch/manual/configuration.html#LevelChangePropagator">LevelChangePropagator</a>.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>If you are concerned about application performance, then use of <code>SLF4JBridgeHandler</code>
|
||||
* is appropriate only if any one the following two conditions is true:</p>
|
||||
* is appropriate only if any of the following conditions is true:
|
||||
* <ol>
|
||||
* <li>few j.u.l. logging statements are in play</li>
|
||||
* <li>LevelChangePropagator has been installed</li>
|
||||
|
|
@ -93,7 +93,7 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
* <h2>As a Java 9/Jigsaw module</h2>
|
||||
*
|
||||
* <p>Given that <b>to</b> is a reserved keyword under Java 9 within module productions,
|
||||
* the MAFIFEST.MF file in <em>jul-to-slf4j.jar</em> declares <b>jul_to_slf4j</b> as
|
||||
* the MANIFEST.MF file in <em>jul-to-slf4j.jar</em> declares <b>jul_to_slf4j</b> as
|
||||
* its Automatic Module Name. Thus, if your application is Jigsaw modularized, the requires
|
||||
* statement in your <em>module-info.java</em> needs to be <b>jul_to_slf4j</b>
|
||||
* (note the two underscores).
|
||||
|
|
@ -118,9 +118,8 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
|
||||
/**
|
||||
* Adds a SLF4JBridgeHandler instance to jul's root logger.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* This handler will redirect j.u.l. logging to SLF4J. However, only logs enabled
|
||||
*
|
||||
* <p>This handler will redirect j.u.l. logging to SLF4J. However, only logs enabled
|
||||
* in j.u.l. will be redirected. For example, if a log statement invoking a
|
||||
* j.u.l. logger is disabled, then the corresponding non-event will <em>not</em>
|
||||
* reach SLF4JBridgeHandler and cannot be redirected.
|
||||
|
|
@ -144,9 +143,9 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
public static void uninstall() throws SecurityException {
|
||||
java.util.logging.Logger rootLogger = getRootLogger();
|
||||
Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
if (handlers[i] instanceof SLF4JBridgeHandler) {
|
||||
rootLogger.removeHandler(handlers[i]);
|
||||
for (Handler handler : handlers) {
|
||||
if (handler instanceof SLF4JBridgeHandler) {
|
||||
rootLogger.removeHandler(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,14 +153,14 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
/**
|
||||
* Returns true if SLF4JBridgeHandler has been previously installed, returns false otherwise.
|
||||
*
|
||||
* @return true if SLF4JBridgeHandler is already installed, false other wise
|
||||
* @throws SecurityException
|
||||
* @return true if SLF4JBridgeHandler is already installed, false otherwise
|
||||
*
|
||||
*/
|
||||
public static boolean isInstalled() throws SecurityException {
|
||||
public static boolean isInstalled() {
|
||||
java.util.logging.Logger rootLogger = getRootLogger();
|
||||
Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
if (handlers[i] instanceof SLF4JBridgeHandler) {
|
||||
for (Handler handler : handlers) {
|
||||
if (handler instanceof SLF4JBridgeHandler) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -175,8 +174,8 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
public static void removeHandlersForRootLogger() {
|
||||
java.util.logging.Logger rootLogger = getRootLogger();
|
||||
java.util.logging.Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
rootLogger.removeHandler(handlers[i]);
|
||||
for (Handler handler : handlers) {
|
||||
rootLogger.removeHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +201,9 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
|
||||
/**
|
||||
* Return the Logger instance that will be used for logging.
|
||||
*
|
||||
* @param record a LogRecord
|
||||
* @return an SLF4J logger corresponding to the record parameter's logger name
|
||||
*/
|
||||
protected Logger getSLF4JLogger(LogRecord record) {
|
||||
String name = record.getLoggerName();
|
||||
|
|
@ -283,10 +285,10 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
|
||||
/**
|
||||
* Publish a LogRecord.
|
||||
* <p/>
|
||||
* <p>
|
||||
* The logging request was made initially to a Logger object, which
|
||||
* initialized the LogRecord and forwarded it here.
|
||||
* <p/>
|
||||
* <p>
|
||||
* This handler ignores the Level attached to the LogRecord, as SLF4J cares
|
||||
* about discarding log statements.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
<p>Bridge/route all JUL log records to the SLF4J API.</p>
|
||||
|
||||
<hr/>
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
module jul.to.slf4j {
|
||||
|
||||
requires org.slf4j;
|
||||
requires java.logging;
|
||||
|
||||
exports org.slf4j.bridge;
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: jul.to.slf4j
|
||||
Bundle-Name: jul-to-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Export-Package: org.slf4j.bridge;version=${parsedVersion.osgiVersion};uses:="org.slf4j,org.slf4j.spi"
|
||||
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion},org.slf4j.spi;version=${parsedVersion.osgiVersion}
|
||||
Automatic-Module-Name: jul.to.slf4j
|
||||
|
|
@ -32,7 +32,7 @@ import org.apache.log4j.spi.LoggingEvent;
|
|||
|
||||
public class ListAppender extends AppenderSkeleton {
|
||||
|
||||
public List<LoggingEvent> list = new ArrayList<LoggingEvent>();
|
||||
public List<LoggingEvent> list = new ArrayList<>();
|
||||
|
||||
public boolean extractLocationInfo = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ public class SLF4JBridgeHandlerPerfTest {
|
|||
fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");
|
||||
|
||||
existingHandlers = julRootLogger.getHandlers();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.removeHandler(existingHandlers[i]);
|
||||
for (Handler existingHandler : existingHandlers) {
|
||||
julRootLogger.removeHandler(existingHandler);
|
||||
}
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(fileAppender);
|
||||
|
|
@ -68,8 +68,8 @@ public class SLF4JBridgeHandlerPerfTest {
|
|||
SLF4JBridgeHandler.uninstall();
|
||||
fileAppender.close();
|
||||
log4jRoot.getLoggerRepository().resetConfiguration();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.addHandler(existingHandlers[i]);
|
||||
for (Handler existingHandler : existingHandlers) {
|
||||
julRootLogger.addHandler(existingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,14 +42,16 @@ public class SLF4JBridgeHandlerTest {
|
|||
|
||||
ListAppender listAppender = new ListAppender();
|
||||
org.apache.log4j.Logger log4jRoot;
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("yay");
|
||||
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(LOGGER_NAME);
|
||||
java.util.logging.Logger julRootLogger = java.util.logging.Logger.getLogger("");
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
listAppender.extractLocationInfo = true;
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(listAppender);
|
||||
log4jRoot.setLevel(org.apache.log4j.Level.TRACE);
|
||||
julRootLogger.setLevel(Level.FINEST);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
@ -61,6 +63,7 @@ public class SLF4JBridgeHandlerTest {
|
|||
@Test
|
||||
public void testSmoke() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String msg = "msg";
|
||||
julLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
|
|
@ -77,6 +80,19 @@ public class SLF4JBridgeHandlerTest {
|
|||
assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
|
||||
assertEquals("testSmoke", li.getMethodName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LOGBACK_1612() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String msg = "LOGBACK_1612";
|
||||
julLogger.finer(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(msg, le.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLevels() {
|
||||
|
|
@ -101,6 +117,8 @@ public class SLF4JBridgeHandlerTest {
|
|||
assertLevel(i++, org.apache.log4j.Level.ERROR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testLogWithResourceBundle() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
|
@ -115,7 +133,7 @@ public class SLF4JBridgeHandlerTest {
|
|||
|
||||
julResourceBundleLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
LoggingEvent le = listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(expectedMsg, le.getMessage());
|
||||
}
|
||||
|
|
@ -149,19 +167,19 @@ public class SLF4JBridgeHandlerTest {
|
|||
|
||||
LoggingEvent le = null;
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(0);
|
||||
le = listAppender.list.get(0);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg1, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(1);
|
||||
le = listAppender.list.get(1);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg2, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(2);
|
||||
le = listAppender.list.get(2);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(3);
|
||||
le = listAppender.list.get(3);
|
||||
assertEquals("yay", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
}
|
||||
|
|
@ -173,7 +191,7 @@ public class SLF4JBridgeHandlerTest {
|
|||
julLogger.logp(Level.INFO, "SLF4JBridgeHandlerTest", "testLogWithPlaceholderNoParameters", msg, new Object[0]);
|
||||
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
LoggingEvent le = listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(msg, le.getMessage());
|
||||
}
|
||||
|
|
@ -187,7 +205,7 @@ public class SLF4JBridgeHandlerTest {
|
|||
|
||||
julLogger.log(Level.INFO, msg, "ignored parameter due to IllegalArgumentException");
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
LoggingEvent le = listAppender.list.get(0);
|
||||
assertEquals(msg, le.getMessage());
|
||||
}
|
||||
|
||||
|
|
@ -197,12 +215,12 @@ public class SLF4JBridgeHandlerTest {
|
|||
String msg = null;
|
||||
julLogger.log(Level.INFO, msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
LoggingEvent le = listAppender.list.get(0);
|
||||
assertEquals("", le.getMessage());
|
||||
}
|
||||
|
||||
|
||||
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
|
||||
LoggingEvent le = listAppender.list.get(index);
|
||||
assertEquals(expectedLevel, le.getLevel());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
<project name="testing-log4j-bridge" default="usage" basedir=".">
|
||||
|
||||
<property name="lbversion" value="0.9.8-SNAPSHOT" />
|
||||
<property name="slf4jversion" value="1.4.2" />
|
||||
<property name="source.home" value="./src/main/java/" />
|
||||
<property name="javac.dest.12" value="./target/classes12/" />
|
||||
<property name="javac.dest.13" value="./target/classes13/" />
|
||||
<property name="lib" value="./lib" />
|
||||
|
||||
<property name="deprecation" value="on" />
|
||||
|
||||
<path id="basic.classpath">
|
||||
<pathelement location="${source.home}" />
|
||||
<pathelement location="${lib}/junit-3.8.1.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j12.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.12}" />
|
||||
<pathelement location="${lib}/log4j-1.2.14.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j13.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.13}" />
|
||||
<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
|
||||
</path>
|
||||
|
||||
<path id="los.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${lib}/log4j-over-slf4j-${slf4jversion}.jar" />
|
||||
<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/logback-core-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
|
||||
</path>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Default target -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="usage">
|
||||
<echo>
|
||||
These are some of the targets supported by this ANT build scpript:
|
||||
|
||||
all - run all available tests
|
||||
refresh - copy required jar files to the lib directory
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<delete>
|
||||
<fileset dir="." includes="**/*.bak"/>
|
||||
</delete>
|
||||
|
||||
<target name="refresh">
|
||||
<delete>
|
||||
<fileset dir="lib">
|
||||
<include name="logback-*.jar"/>
|
||||
<include name="log4j-bridge-*.jar"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<copy file="../../slf4j-api/target/slf4j-api-${slf4jversion}.jar" todir="lib/"/>
|
||||
<copy file="../target/log4j-over-slf4j-${slf4jversion}.jar" todir="lib/"/>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${javac.dest.12}" />
|
||||
<mkdir dir="${javac.dest.13}" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="${javac.dest.12}" includes="**" />
|
||||
<fileset dir="${javac.dest.13}" includes="**" />
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j12" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/Log4j12Calls.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j12.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j13" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.13}"
|
||||
includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j13.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_loggerTest" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/LoggerTest.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="los.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Run tests -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="all" depends="test12, test13, loggerTest" />
|
||||
|
||||
|
||||
<target name="loggerTest" depends="build_loggerTest">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.LoggerTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test12" depends="build_log4j12">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j12Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test13" depends="build_log4j13">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.13}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j13Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
This directory is used to test the module against various log4j calls.
|
||||
Two test cases simulate the typical calls that one can find in an application
|
||||
that uses either log4j 1.2.x, or log4j 1.3.x.
|
||||
|
||||
In the same directory is a build.xml file that uses ant to
|
||||
compile the test cases with the corresponding log4j version,
|
||||
and to runs these tests without log4j in the classpath but with
|
||||
logback jars instead.
|
||||
|
||||
To run the tests, one must have ant installed. Issuing the following command,
|
||||
once in the compatibility directory will launch the tests:
|
||||
|
||||
ant all
|
||||
|
||||
To obtain more information about the use of the log4j-over-slf4j module,
|
||||
please visit http://www..slf4j.org/log4j-over-slf4j.html
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package test;
|
||||
|
||||
public class DummyObject {
|
||||
|
||||
public String toString() {
|
||||
return "dummy";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.2 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
public class Log4j12Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.3 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
|
||||
public class Log4j13Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.info("The answer is {}.", new Integer(42));
|
||||
logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24));
|
||||
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
/**
|
||||
* A class that tests the invocation of the org.apache.log4j.Logger class that
|
||||
* belongs to the log4j-bridge package
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
|
||||
public class LoggerTest extends TestCase {
|
||||
|
||||
LoggerContext context;
|
||||
ListAppender<LoggingEvent> appender;
|
||||
ch.qos.logback.classic.Logger logbackLogger;
|
||||
org.apache.log4j.Logger log4jLogger;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
context.shutdownAndReset();
|
||||
appender = new ListAppender<LoggingEvent>();
|
||||
appender.setContext(context);
|
||||
appender.setName("listAppender");
|
||||
appender.start();
|
||||
ch.qos.logback.classic.Logger lbLogger = context
|
||||
.getLogger(LoggerContext.ROOT_NAME);
|
||||
lbLogger.addAppender(appender);
|
||||
|
||||
log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class);
|
||||
logbackLogger = context.getLogger(LoggerTest.class);
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
appender.stop();
|
||||
context.stop();
|
||||
appender = null;
|
||||
context = null;
|
||||
logbackLogger = null;
|
||||
log4jLogger = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testLogWithObjectMessages() {
|
||||
LoggingEvent event;
|
||||
|
||||
log4jLogger.debug("test");
|
||||
event = appender.list.get(0);
|
||||
assertEquals("test", event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(null, event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
DummyObject dummy = new DummyObject();
|
||||
log4jLogger.debug(dummy);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(dummy.toString(), event.getMessage());
|
||||
appender.list.clear();
|
||||
}
|
||||
|
||||
public void testIsEnabledAPI() {
|
||||
assertFalse(log4jLogger.isTraceEnabled());
|
||||
assertTrue(log4jLogger.isDebugEnabled());
|
||||
assertTrue(log4jLogger.isInfoEnabled());
|
||||
assertTrue(log4jLogger.isWarnEnabled());
|
||||
assertTrue(log4jLogger.isErrorEnabled());
|
||||
}
|
||||
|
||||
public void testPrintAPI() {
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
log4jLogger.trace(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
public void testLogAPI() {
|
||||
log4jLogger.log("x", Level.TRACE, "x", null);
|
||||
assertEquals(0, appender.list.size());
|
||||
|
||||
log4jLogger.log("x", Level.DEBUG, "x", null);
|
||||
log4jLogger.log("x", Level.INFO, "x", null);
|
||||
log4jLogger.log("x", Level.WARN, "x", null);
|
||||
log4jLogger.log("x", Level.ERROR, "x", null);
|
||||
log4jLogger.log("x", Level.FATAL, "x", null);
|
||||
|
||||
assertEquals(5, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
|
|
@ -20,8 +21,8 @@
|
|||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache Software Licenses</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<name>Apache-2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
|
@ -41,4 +42,20 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<_exportcontents>org.apache.log4j*;version=${reload4j.version};-noimport:=true</_exportcontents>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public interface Appender {
|
|||
/**
|
||||
* Release any resources allocated within the appender such as file
|
||||
* handles, network connections, etc.
|
||||
* <p/>
|
||||
*
|
||||
* <p>It is a programming error to append to a closed appender.
|
||||
*
|
||||
* @since 0.8.4
|
||||
|
|
@ -114,12 +114,12 @@ public interface Appender {
|
|||
* Configurators call this method to determine if the appender
|
||||
* requires a layout. If this method returns <code>true</code>,
|
||||
* meaning that layout is required, then the configurator will
|
||||
* configure an layout using the configuration information at its
|
||||
* configure a layout using the configuration information at its
|
||||
* disposal. If this method returns <code>false</code>, meaning that
|
||||
* a layout is not required, then layout configuration will be
|
||||
* skipped even if there is available layout configuration
|
||||
* information at the disposal of the configurator.
|
||||
* <p/>
|
||||
*
|
||||
* <p>In the rather exceptional case, where the appender
|
||||
* implementation admits a layout but can also work without it, then
|
||||
* the appender should return <code>true</code>.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import java.util.Enumeration;
|
|||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) by
|
||||
* delegation of all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>,
|
||||
|
|
@ -45,12 +45,12 @@ public class Category {
|
|||
|
||||
private static final String CATEGORY_FQCN = Category.class.getName();
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
protected org.slf4j.Logger slf4jLogger;
|
||||
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
|
||||
|
||||
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
private static final Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
|
||||
Category(String name) {
|
||||
this.name = name;
|
||||
|
|
@ -125,6 +125,7 @@ public class Category {
|
|||
|
||||
/**
|
||||
* @deprecated Please use {@link #getLevel} instead.
|
||||
* @return a Level
|
||||
*/
|
||||
final public Level getPriority() {
|
||||
return null;
|
||||
|
|
@ -132,6 +133,9 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J
|
||||
*
|
||||
* @return true if this logger is enabled for the level DEBUG
|
||||
*
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return slf4jLogger.isDebugEnabled();
|
||||
|
|
@ -139,6 +143,8 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J
|
||||
*
|
||||
* @return true if this logger is enabled for the level INFO
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return slf4jLogger.isInfoEnabled();
|
||||
|
|
@ -146,6 +152,8 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J
|
||||
*
|
||||
* @return true if this logger is enabled for the level WARN
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return slf4jLogger.isWarnEnabled();
|
||||
|
|
@ -153,6 +161,8 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J
|
||||
*
|
||||
* @return true if this logger is enabled for the level ERROR
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
|
|
@ -160,13 +170,11 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Determines whether the priority passed as parameter is enabled in the
|
||||
* underlying SLF4J logger. Each log4j priority is mapped directly to its
|
||||
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
|
||||
* underlying SLF4J logger. Each log4j priority is mapped directly to its SLF4J
|
||||
* equivalent, except for FATAL which is mapped as ERROR.
|
||||
*
|
||||
* @param p
|
||||
* the priority to check against
|
||||
* @return true if this logger is enabled for the given level, false
|
||||
* otherwise.
|
||||
* @param p the priority to check against
|
||||
* @return true if this logger is enabled for the given level, false otherwise.
|
||||
*/
|
||||
public boolean isEnabledFor(Priority p) {
|
||||
switch (p.level) {
|
||||
|
|
@ -194,19 +202,19 @@ public class Category {
|
|||
} else {
|
||||
switch (level) {
|
||||
case LocationAwareLogger.TRACE_INT:
|
||||
slf4jLogger.trace(marker, m);
|
||||
slf4jLogger.trace(marker, m, (Throwable) t);
|
||||
break;
|
||||
case LocationAwareLogger.DEBUG_INT:
|
||||
slf4jLogger.debug(marker, m);
|
||||
slf4jLogger.debug(marker, m, (Throwable) t);
|
||||
break;
|
||||
case LocationAwareLogger.INFO_INT:
|
||||
slf4jLogger.info(marker, m);
|
||||
slf4jLogger.info(marker, m, (Throwable) t);
|
||||
break;
|
||||
case LocationAwareLogger.WARN_INT:
|
||||
slf4jLogger.warn(marker, m);
|
||||
slf4jLogger.warn(marker, m, (Throwable) t);
|
||||
break;
|
||||
case LocationAwareLogger.ERROR_INT:
|
||||
slf4jLogger.error(marker, m);
|
||||
slf4jLogger.error(marker, m, (Throwable) t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -214,6 +222,8 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, null);
|
||||
|
|
@ -222,6 +232,9 @@ public class Category {
|
|||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
* @param t a throwable to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, t);
|
||||
|
|
@ -229,14 +242,18 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
*/
|
||||
public void info(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
* @param t a throwable to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, t);
|
||||
|
|
@ -244,14 +261,20 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
*
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
* @param t a throwable to log
|
||||
*
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, t);
|
||||
|
|
@ -259,6 +282,9 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
*
|
||||
*/
|
||||
public void error(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
|
||||
|
|
@ -267,6 +293,10 @@ public class Category {
|
|||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
* @param t a throwable to log
|
||||
*
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
|
||||
|
|
@ -274,6 +304,9 @@ public class Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*
|
||||
* @param message a message to log
|
||||
*
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
|
||||
|
|
@ -282,6 +315,10 @@ public class Category {
|
|||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J. In addition, the call is marked with a marker named "FATAL".
|
||||
*
|
||||
* @param message a message to log
|
||||
* @param t a throwable to log
|
||||
*
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,18 @@
|
|||
*/
|
||||
package org.apache.log4j;
|
||||
|
||||
/**
|
||||
* Skeleton implementation of ConsoleAppender
|
||||
*/
|
||||
public class ConsoleAppender extends WriterAppender {
|
||||
|
||||
public ConsoleAppender() {
|
||||
}
|
||||
|
||||
public ConsoleAppender(Layout layout) {
|
||||
}
|
||||
|
||||
public ConsoleAppender(Layout layout, String target) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.log4j;
|
|||
/**
|
||||
* This class is a minimal implementation of the original Log4J class.
|
||||
*
|
||||
* @author Christian Trutz <christian.trutz@belaso.de>
|
||||
* @author Christian Trutz
|
||||
* */
|
||||
public class Layout {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,21 +26,21 @@ import java.io.ObjectStreamException;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
Defines the minimum set of levels recognized by the system, that is
|
||||
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
|
||||
<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
|
||||
<code>ALL</code>.
|
||||
|
||||
<p>The <code>Level</code> class may be subclassed to define a larger
|
||||
level set.
|
||||
|
||||
@author Ceki Gülcü
|
||||
|
||||
* Defines the minimum set of levels recognized by the system, that is
|
||||
* <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>, <code>WARN</code>,
|
||||
* <code>INFO</code>, <code>DEBUG</code> and <code>ALL</code>.
|
||||
*
|
||||
* <p>
|
||||
* The <code>Level</code> class may be subclassed to define a larger level set.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*/
|
||||
public class Level extends Priority implements Serializable {
|
||||
|
||||
/**
|
||||
* TRACE level integer value.
|
||||
*
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final int TRACE_INT = 5000;
|
||||
|
|
@ -49,48 +49,52 @@ public class Level extends Priority implements Serializable {
|
|||
public static final int X_TRACE_INT = DEBUG_INT - 100;
|
||||
|
||||
/**
|
||||
The <code>OFF</code> has the highest possible rank and is
|
||||
intended to turn off logging. */
|
||||
* The <code>OFF</code> has the highest possible rank and is intended to turn
|
||||
* off logging.
|
||||
*/
|
||||
final static public Level OFF = new Level(OFF_INT, "OFF", 0);
|
||||
|
||||
/**
|
||||
The <code>FATAL</code> level designates very severe error
|
||||
events that will presumably lead the application to abort.
|
||||
* The <code>FATAL</code> level designates very severe error events that will
|
||||
* presumably lead the application to abort.
|
||||
*/
|
||||
final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
|
||||
|
||||
/**
|
||||
The <code>ERROR</code> level designates error events that
|
||||
might still allow the application to continue running. */
|
||||
* The <code>ERROR</code> level designates error events that might still allow
|
||||
* the application to continue running.
|
||||
*/
|
||||
final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
|
||||
|
||||
/**
|
||||
The <code>WARN</code> level designates potentially harmful situations.
|
||||
*/
|
||||
* The <code>WARN</code> level designates potentially harmful situations.
|
||||
*/
|
||||
final static public Level WARN = new Level(WARN_INT, "WARN", 4);
|
||||
|
||||
/**
|
||||
The <code>INFO</code> level designates informational messages
|
||||
that highlight the progress of the application at coarse-grained
|
||||
level. */
|
||||
* The <code>INFO</code> level designates informational messages that highlight
|
||||
* the progress of the application at coarse-grained level.
|
||||
*/
|
||||
final static public Level INFO = new Level(INFO_INT, "INFO", 6);
|
||||
|
||||
/**
|
||||
The <code>DEBUG</code> Level designates fine-grained
|
||||
informational events that are most useful to debug an
|
||||
application. */
|
||||
* The <code>DEBUG</code> Level designates fine-grained informational events
|
||||
* that are most useful to debug an application.
|
||||
*/
|
||||
final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
|
||||
|
||||
/**
|
||||
* The <code>TRACE</code> Level designates finer-grained
|
||||
* informational events than the <code>DEBUG</code level.
|
||||
* @since 1.2.12
|
||||
*/
|
||||
* The <code>TRACE</code> Level designates finer-grained informational events
|
||||
* than the <code>DEBUG</code> level.
|
||||
*
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
|
||||
|
||||
/**
|
||||
The <code>ALL</code> has the lowest possible rank and is intended to
|
||||
turn on all logging. */
|
||||
* The <code>ALL</code> has the lowest possible rank and is intended to turn on
|
||||
* all logging.
|
||||
*/
|
||||
final static public Level ALL = new Level(ALL_INT, "ALL", 7);
|
||||
|
||||
/**
|
||||
|
|
@ -99,33 +103,47 @@ public class Level extends Priority implements Serializable {
|
|||
static final long serialVersionUID = 3491141966387921974L;
|
||||
|
||||
/**
|
||||
Instantiate a Level object.
|
||||
* Instantiate a Level object.
|
||||
*
|
||||
* @param level a level
|
||||
* @param levelStr a level string
|
||||
* @param syslogEquivalent the Syslog equivalent
|
||||
*/
|
||||
protected Level(int level, String levelStr, int syslogEquivalent) {
|
||||
super(level, levelStr, syslogEquivalent);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
*/
|
||||
* Convert the string passed as argument to a level. If the conversion fails,
|
||||
* then this method returns {@link #DEBUG}.
|
||||
*
|
||||
* @param sArg a string
|
||||
* @return corresponding Level
|
||||
*
|
||||
*/
|
||||
public static Level toLevel(String sArg) {
|
||||
return (Level) toLevel(sArg, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
|
||||
*/
|
||||
* Convert an integer passed as argument to a level. If the conversion fails,
|
||||
* then this method returns {@link #DEBUG}.
|
||||
*
|
||||
* @param val an int
|
||||
* @return a level
|
||||
*/
|
||||
public static Level toLevel(int val) {
|
||||
return (Level) toLevel(val, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns the specified default.
|
||||
*/
|
||||
* Convert an integer passed as argument to a level. If the conversion fails,
|
||||
* then this method returns the specified default.
|
||||
*
|
||||
* @param val a value
|
||||
* @param defaultLevel a defaultLevel
|
||||
* @return corresponding Level
|
||||
*/
|
||||
public static Level toLevel(int val, Level defaultLevel) {
|
||||
switch (val) {
|
||||
case ALL_INT:
|
||||
|
|
@ -150,10 +168,13 @@ public class Level extends Priority implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns the value of
|
||||
<code>defaultLevel</code>.
|
||||
*/
|
||||
* Convert the string passed as argument to a level. If the conversion fails,
|
||||
* then this method returns the value of <code>defaultLevel</code>.
|
||||
*
|
||||
* @param sArg a string
|
||||
* @param defaultLevel a default level
|
||||
* @return corresponding level
|
||||
*/
|
||||
public static Level toLevel(String sArg, Level defaultLevel) {
|
||||
if (sArg == null)
|
||||
return defaultLevel;
|
||||
|
|
@ -181,8 +202,9 @@ public class Level extends Priority implements Serializable {
|
|||
|
||||
/**
|
||||
* Custom deserialization of Level.
|
||||
*
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if IO exception.
|
||||
* @throws IOException if IO exception.
|
||||
* @throws ClassNotFoundException if class not found.
|
||||
*/
|
||||
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
|
||||
|
|
@ -197,6 +219,7 @@ public class Level extends Priority implements Serializable {
|
|||
|
||||
/**
|
||||
* Serialize level.
|
||||
*
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if exception during serialization.
|
||||
*/
|
||||
|
|
@ -208,8 +231,9 @@ public class Level extends Priority implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Resolved deserialized level to one of the stock instances.
|
||||
* May be overridden in classes derived from Level.
|
||||
* Resolved deserialized level to one of the stock instances. May be overridden
|
||||
* in classes derived from Level.
|
||||
*
|
||||
* @return resolved object.
|
||||
* @throws ObjectStreamException if exception during resolution.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||
class Log4jLoggerFactory {
|
||||
|
||||
// String, Logger
|
||||
private static ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<String, Logger>();
|
||||
private static final ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<>();
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
org.apache.log4j.Logger instance = log4jLoggers.get(name);
|
||||
|
|
|
|||
|
|
@ -22,12 +22,11 @@ import java.util.Enumeration;
|
|||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.LogManager</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to SLF4J.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* This implementation does <b>NOT</b> implement the setRepositorySelector(),
|
||||
* getLoggerRepository(), exists(), getCurrentLoggers(), shutdown() and
|
||||
* resetConfiguration() methods which do not have SLF4J equivalents.
|
||||
|
|
@ -67,7 +66,7 @@ public class LogManager {
|
|||
/**
|
||||
* This bogus implementation returns an empty enumeration.
|
||||
*
|
||||
* @return
|
||||
* @return an Enumeration of current loggers
|
||||
*/
|
||||
public static Enumeration getCurrentLoggers() {
|
||||
return new Vector().elements();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.slf4j.spi.LocationAwareLogger;
|
|||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* */
|
||||
|
|
@ -52,7 +52,7 @@ public class Logger extends Category {
|
|||
/**
|
||||
* Does the obvious.
|
||||
*
|
||||
* @return
|
||||
* @return the root logger
|
||||
*/
|
||||
public static Logger getRootLogger() {
|
||||
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
|
|
@ -61,6 +61,8 @@ public class Logger extends Category {
|
|||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isTraceEnabled}
|
||||
* method of SLF4J.
|
||||
*
|
||||
* @return whether this logger is enabled for the level TRACE
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return slf4jLogger.isTraceEnabled();
|
||||
|
|
@ -68,6 +70,9 @@ public class Logger extends Category {
|
|||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
|
||||
*
|
||||
* @param message the message to log
|
||||
*
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
|
|
@ -76,9 +81,12 @@ public class Logger extends Category {
|
|||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String,Throwable)}
|
||||
* method in SLF4J.
|
||||
*
|
||||
* @param message the message to log
|
||||
* @param t a Throwable to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class MDC {
|
|||
* This method is not part of the Log4J public API. However it
|
||||
* has been called by other projects. This method is here temporarily
|
||||
* until projects who are depending on this method release fixes.
|
||||
*
|
||||
* @return a copy of the underlying map returned as a Hashtable
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Deprecated
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.log4j;
|
|||
/**
|
||||
* This class is a minimal implementation of the original Log4J class.
|
||||
*
|
||||
* @author Christian Trutz <christian.trutz@belaso.de>
|
||||
* @author Christian Trutz
|
||||
* */
|
||||
public class PatternLayout extends Layout {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ package org.apache.log4j;
|
|||
// Contributors: Kitching Simon <Simon.Kitching@OOOrange.ch>
|
||||
|
||||
/**
|
||||
<font color="#AA4444">Refrain from using this class directly, use
|
||||
the {@link Level} class instead</font>.
|
||||
<b>Refrain from using this class directly, use
|
||||
the {@link Level} class instead</b>.
|
||||
|
||||
@author Ceki Gülcü */
|
||||
public class Priority {
|
||||
|
|
@ -80,6 +80,15 @@ public class Priority {
|
|||
|
||||
/**
|
||||
Instantiate a level object.
|
||||
@param
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instantiate a level object.
|
||||
*
|
||||
* @param level a level as in int
|
||||
* @param levelStr a levelStr
|
||||
* @param syslogEquivalent the syslog equivalent level integer
|
||||
*/
|
||||
protected Priority(int level, String levelStr, int syslogEquivalent) {
|
||||
this.level = level;
|
||||
|
|
@ -102,20 +111,23 @@ public class Priority {
|
|||
|
||||
/**
|
||||
Return the syslog equivalent of this priority as an integer.
|
||||
@return the Syslog Equivalent of this Priority
|
||||
*/
|
||||
public final int getSyslogEquivalent() {
|
||||
return syslogEquivalent;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns <code>true</code> if this level has a higher or equal
|
||||
level than the level passed as argument, <code>false</code>
|
||||
otherwise.
|
||||
|
||||
<p>You should think twice before overriding the default
|
||||
implementation of <code>isGreaterOrEqual</code> method.
|
||||
|
||||
*/
|
||||
* Returns <code>true</code> if this level has a higher or equal
|
||||
* level than the level passed as argument, <code>false</code>
|
||||
* otherwise.
|
||||
*
|
||||
* <p>You should think twice before overriding the default
|
||||
* implementation of <code>isGreaterOrEqual</code> method.
|
||||
*
|
||||
* @param r a priority
|
||||
* @return a boolean
|
||||
*/
|
||||
public boolean isGreaterOrEqual(Priority r) {
|
||||
return level >= r.level;
|
||||
}
|
||||
|
|
@ -123,8 +135,9 @@ public class Priority {
|
|||
/**
|
||||
Return all possible priorities as an array of Level objects in
|
||||
descending order.
|
||||
|
||||
|
||||
@deprecated This method will be removed with no replacement.
|
||||
@return array of all possible priorities
|
||||
*/
|
||||
@Deprecated
|
||||
public static Priority[] getAllPossiblePriorities() {
|
||||
|
|
@ -139,7 +152,9 @@ public class Priority {
|
|||
}
|
||||
|
||||
/**
|
||||
Returns the integer representation of this level.
|
||||
* Returns the integer representation of this level.
|
||||
*
|
||||
* @return integer representation of this level
|
||||
*/
|
||||
public final int toInt() {
|
||||
return level;
|
||||
|
|
@ -147,6 +162,9 @@ public class Priority {
|
|||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String)} method instead.
|
||||
*
|
||||
* @param sArg a string to convert to a Priority
|
||||
* @return the corresponding Priority
|
||||
*/
|
||||
@Deprecated
|
||||
public static Priority toPriority(String sArg) {
|
||||
|
|
@ -155,6 +173,9 @@ public class Priority {
|
|||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int)} method instead.
|
||||
*
|
||||
* @param val an integer to convert to a Priority
|
||||
* @return the corresponding Priority
|
||||
*/
|
||||
@Deprecated
|
||||
public static Priority toPriority(int val) {
|
||||
|
|
@ -163,7 +184,11 @@ public class Priority {
|
|||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
|
||||
*/
|
||||
*
|
||||
* @param val an integer value
|
||||
* @param defaultPriority a default priority value
|
||||
* @return corresponding Priority value
|
||||
*/
|
||||
@Deprecated
|
||||
public static Priority toPriority(int val, Priority defaultPriority) {
|
||||
return Level.toLevel(val, (Level) defaultPriority);
|
||||
|
|
@ -171,9 +196,12 @@ public class Priority {
|
|||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
|
||||
* @param sArg string value
|
||||
* @param defaultPriority a default Priority
|
||||
* @return a Priority
|
||||
*/
|
||||
@Deprecated
|
||||
public static Priority toPriority(String sArg, Priority defaultPriority) {
|
||||
return Level.toLevel(sArg, (Level) defaultPriority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.apache.log4j.spi.Configurator;
|
|||
import org.apache.log4j.spi.LoggerRepository;
|
||||
|
||||
/**
|
||||
* An nop implementation of PropertyConfigurator.
|
||||
* A no-op implementation of PropertyConfigurator.
|
||||
*/
|
||||
public class PropertyConfigurator implements Configurator {
|
||||
public static void configure(Properties properties) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* This class is a minimal implementation of the original Log4J class.
|
||||
*
|
||||
* @author Christian Trutz <christian.trutz@belaso.de>
|
||||
* @author Christian Trutz
|
||||
* */
|
||||
public class RollingFileAppender {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ package org.apache.log4j.helpers;
|
|||
<b>log4j.configDebug</b> variable.
|
||||
|
||||
<p>All log4j internal debug calls go to <code>System.out</code>
|
||||
where as internal error messages are sent to
|
||||
whereas internal error messages are sent to
|
||||
<code>System.err</code>. All internal messages are prepended with
|
||||
the string "log4j: ".
|
||||
|
||||
|
|
@ -37,20 +37,20 @@ public class LogLog {
|
|||
/**
|
||||
Defining this value makes log4j print log4j-internal debug
|
||||
statements to <code>System.out</code>.
|
||||
|
||||
|
||||
<p> The value of this string is <b>log4j.debug</b>.
|
||||
|
||||
<p>Note that the search for all option names is case sensitive. */
|
||||
|
||||
<p>Note that the search for all option names is case-sensitive. */
|
||||
public static final String DEBUG_KEY = "log4j.debug";
|
||||
|
||||
/**
|
||||
Defining this value makes log4j components print log4j-internal
|
||||
debug statements to <code>System.out</code>.
|
||||
|
||||
|
||||
<p> The value of this string is <b>log4j.configDebug</b>.
|
||||
|
||||
<p>Note that the search for all option names is case sensitive.
|
||||
|
||||
|
||||
<p>Note that the search for all option names is case-sensitive.
|
||||
|
||||
@deprecated Use {@link #DEBUG_KEY} instead.
|
||||
*/
|
||||
public static final String CONFIG_DEBUG_KEY = "log4j.configDebug";
|
||||
|
|
@ -127,7 +127,7 @@ public class LogLog {
|
|||
/**
|
||||
In quite mode no LogLog generates strictly no output, not even
|
||||
for errors.
|
||||
|
||||
|
||||
@param quietMode A true for not
|
||||
*/
|
||||
public static void setQuietMode(boolean quietMode) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.apache.log4j.spi;
|
||||
|
||||
import org.apache.log4j.spi.LoggerRepository;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
|
|
@ -41,10 +40,10 @@ public interface Configurator {
|
|||
|
||||
/**
|
||||
Interpret a resource pointed by a URL and set up log4j accordingly.
|
||||
|
||||
|
||||
The configuration is done relative to the <code>hierarchy</code>
|
||||
parameter.
|
||||
|
||||
|
||||
@param url The URL to parse
|
||||
@param repository The hierarchy to operation upon.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
|
|||
/**
|
||||
|
||||
Implement this interface to create new instances of Logger or
|
||||
a sub-class of Logger.
|
||||
a subclass of Logger.
|
||||
|
||||
<p>See <code>examples/subclass/MyLogger.java</code> for an example.
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.Enumeration;
|
|||
* <code>Loggers</code>. The relation between loggers in a repository
|
||||
* depends on the repository but typically loggers are arranged in a
|
||||
* named hierarchy.
|
||||
* <p/>
|
||||
*
|
||||
* <p>In addition to the creational methods, a
|
||||
* <code>LoggerRepository</code> can be queried for existing loggers,
|
||||
* can act as a point of registry for events related to loggers.
|
||||
|
|
@ -37,6 +37,8 @@ public interface LoggerRepository {
|
|||
|
||||
/**
|
||||
* Add a {@link HierarchyEventListener} event to the repository.
|
||||
*
|
||||
* @param listener a listener
|
||||
*/
|
||||
public void addHierarchyEventListener(HierarchyEventListener listener);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
Implementation-Title: log4j-over-slf4j
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: log4j.over.slf4j
|
||||
Bundle-Name: log4j-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Export-Package: org.apache.log4j;version=${log4j.version},
|
||||
org.apache.log4j.helpers;version=${log4j.version},
|
||||
org.apache.log4j.spi;version=${log4j.version},
|
||||
org.apache.log4j.xml;version=${log4j.version}
|
||||
Import-Package: org.slf4j;version=${slf4j.api.minimum.compatible.version},
|
||||
org.slf4j.helpers;version=${slf4j.api.minimum.compatible.version},
|
||||
org.slf4j.spi;version=${slf4j.api.minimum.compatible.version}
|
||||
|
|
@ -31,7 +31,7 @@ import java.util.logging.LogRecord;
|
|||
|
||||
public class ListHandler extends Handler {
|
||||
|
||||
List<LogRecord> list = new ArrayList<LogRecord>();
|
||||
List<LogRecord> list = new ArrayList<>();
|
||||
|
||||
public void close() throws SecurityException {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>osgi-over-slf4j</artifactId>
|
||||
|
|
@ -37,8 +38,27 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>org.slf4j.osgi-over-slf4j</Bundle-SymbolicName>
|
||||
<Bundle-Activator>org.slf4j.osgi.logservice.impl.Activator</Bundle-Activator>
|
||||
<Bundle-Category>osgi</Bundle-Category>
|
||||
<_exportcontents combine.self="override" />
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
Implementation-Title: osgi-over-slf4j
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: org.slf4j.osgi-over-slf4j
|
||||
Bundle-Name: OSGi LogService implemented over SLF4J
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-Activator: org.slf4j.osgi.logservice.impl.Activator
|
||||
Bundle-Category: osgi
|
||||
Import-Package: org.osgi.framework;version="[1.5,2)",org.osgi.service.log;version="[1.3,2)",org.slf4j;version=${parsedVersion.osgiVersion}
|
||||
|
|
@ -0,0 +1,397 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-bom</artifactId>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>SLF4J Parent POM</name>
|
||||
<description>SLF4J project parent pom.xml file</description>
|
||||
|
||||
|
||||
<organization>
|
||||
<name>QOS.ch</name>
|
||||
<url>http://www.qos.ch</url>
|
||||
</organization>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
|
||||
|
||||
<properties>
|
||||
<!-- yyyy-MM-dd'T'HH:mm:ss'Z' -->
|
||||
<project.build.outputTimestamp>2026-05-12T18:37:04Z</project.build.outputTimestamp>
|
||||
<latest.1.version>1.7.36</latest.1.version>
|
||||
<!-- java.util.ServiceLoader requires Java 6 -->
|
||||
<jdk.version>8</jdk.version>
|
||||
<maven.compiler.source>${jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<!-- used in integration testing -->
|
||||
<cal10n.version>0.8.1</cal10n.version>
|
||||
<reload4j.version>1.2.22</reload4j.version>
|
||||
<logback.version>1.2.10</logback.version>
|
||||
<jcl.version>1.2</jcl.version>
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
|
||||
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
|
||||
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
|
||||
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
|
||||
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
|
||||
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
|
||||
<maven-jxr-plugin.version>3.1.1</maven-jxr-plugin.version>
|
||||
<maven-bundle-plugin.version>5.1.9</maven-bundle-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
<artifactId>reload4j</artifactId>
|
||||
<version>${reload4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.cal10n</groupId>
|
||||
<artifactId>cal10n-api</artifactId>
|
||||
<version>${cal10n.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>2.10</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
|
||||
<resource>
|
||||
<directory>..</directory>
|
||||
<targetPath>META-INF</targetPath>
|
||||
<includes>
|
||||
<include>LICENSE.txt</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
<version>1.14</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
<artifactId>java16</artifactId>
|
||||
<version>1.0</version>
|
||||
</signature>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>${maven-deploy-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<executions>
|
||||
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>${jdk.version}</source>
|
||||
<target>${jdk.version}</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>module-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<release>9</release>
|
||||
<compileSourceRoots>
|
||||
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
|
||||
</compileSourceRoots>
|
||||
<multiReleaseOutput>true</multiReleaseOutput>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
<executions>
|
||||
<!-- Repeated in slf4j-api/pom.xml -->
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
<skipIfEmpty>true</skipIfEmpty>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>${maven-bundle-plugin.version}</version>
|
||||
<configuration>
|
||||
<supportIncrementalBuild>true</supportIncrementalBuild>
|
||||
<!-- populated by the plugin itself -->
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${replacestring;${project.artifactId};-;.}</Bundle-SymbolicName>
|
||||
<Bundle-Vendor>SLF4J.ORG</Bundle-Vendor>
|
||||
<_snapshot/>
|
||||
<_exportcontents>!META-INF.versions.9,*;-noimport:=true</_exportcontents>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Bundle-DocURL>${project.url}</Bundle-DocURL>
|
||||
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
||||
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Implementation-Title>${project.artifactId}</Implementation-Title>
|
||||
<Multi-Release>true</Multi-Release>
|
||||
<_removeheaders>Private-Package,Bundle-SCM, Bundle-Developers, Include-Resource</_removeheaders>
|
||||
</instructions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-manifest</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>1</forkCount>
|
||||
<reuseForks>false</reuseForks>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>${maven-site-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>skipTests</id>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>javadocjar</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven-javadoc-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
<failOnError>false</failOnError>
|
||||
<sourceFileExcludes>
|
||||
<sourceFileExclude>**/module-info.java</sourceFileExclude>
|
||||
</sourceFileExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>license</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-license-plugin</groupId>
|
||||
<artifactId>maven-license-plugin</artifactId>
|
||||
<configuration>
|
||||
<header>src/main/licenseHeader.txt</header>
|
||||
<quiet>false</quiet>
|
||||
<failIfMissing>true</failIfMissing>
|
||||
<aggregate>true</aggregate>
|
||||
<includes>
|
||||
<include>src/**/*.java</include>
|
||||
</includes>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<useDefaultMapping>true</useDefaultMapping>
|
||||
<properties>
|
||||
<year>1999</year>
|
||||
</properties>
|
||||
<headerDefinitions>
|
||||
<headerDefinition>src/main/javadocHeaders.xml</headerDefinition>
|
||||
</headerDefinitions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
|
||||
|
||||
<profile>
|
||||
<id>generate-osgi-service-loader-mediator-entries</id>
|
||||
<activation>
|
||||
<file>
|
||||
<exists>src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider</exists>
|
||||
</file>
|
||||
</activation>
|
||||
<build>
|
||||
<!-- Add the OSGi Service Loader Mediator Specification Manifest entries for each module that has a SLF4JServiceProvider Service-Loader file.-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Provide-Capability><![CDATA[
|
||||
osgi.service;objectClass:List<String>="org.slf4j.spi.SLF4JServiceProvider";type=${slf4j.provider.type};effective:=active,
|
||||
osgi.serviceloader;osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider";register:="${slf4j.provider.implementation}";type=${slf4j.provider.type}
|
||||
]]></Provide-Capability>
|
||||
<Require-Capability><![CDATA[
|
||||
osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.registrar)(version>=1.0.0)(!(version>=2.0.0)))"
|
||||
]]></Require-Capability>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!--
|
||||
<profile>
|
||||
<id>travis</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.TRAVIS</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-toolchains-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>toolchain</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
-->
|
||||
</profiles>
|
||||
|
||||
|
||||
</project>
|
||||
599
pom.xml
599
pom.xml
|
|
@ -5,86 +5,53 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
|
||||
<artifactId>slf4j-bom</artifactId>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>SLF4J</name>
|
||||
<description>Top SLF4J project pom.xml file</description>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
|
||||
<organization>
|
||||
<name>QOS.ch</name>
|
||||
<url>http://www.qos.ch</url>
|
||||
</organization>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
<name>SLF4J BOM</name>
|
||||
<description>SLF4J project BOM</description>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>http://www.opensource.org/licenses/mit-license.php</url>
|
||||
<name>MIT</name>
|
||||
<url>https://opensource.org/license/mit</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/qos-ch/slf4j</url>
|
||||
<connection>git@github.com:qos-ch/slf4j.git</connection>
|
||||
</scm>
|
||||
<connection>scm:git:https://github.com/qos-ch/slf4j.git</connection>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<latest.stable.version>1.7.26</latest.stable.version>
|
||||
<!-- java.util.ServiceLoader requires Java 6 -->
|
||||
<jdk.version>1.6</jdk.version>
|
||||
<maven.compiler.source>${jdk.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${jdk.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<!-- used in integration testing -->
|
||||
<slf4j.api.minimum.compatible.version>1.6.0</slf4j.api.minimum.compatible.version>
|
||||
<cal10n.version>0.8.1</cal10n.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<logback.version>1.0.13</logback.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<maven-site-plugin.version>3.6</maven-site-plugin.version>
|
||||
<compiler-plugin.version>3.6.1</compiler-plugin.version>
|
||||
<javadoc.plugin.version>2.10.4</javadoc.plugin.version>
|
||||
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>ceki</id>
|
||||
<name>Ceki Gulcu</name>
|
||||
<email>ceki@qos.ch</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<!-- Inspired by Improving the Maven Bill of Materials (BOM) Pattern -->
|
||||
<!-- https://www.garretwilson.com/blog/2023/06/14/improve-maven-bom-pattern -->
|
||||
<modules>
|
||||
<module>parent</module>
|
||||
<module>slf4j-api</module>
|
||||
<module>slf4j-simple</module>
|
||||
<module>slf4j-nop</module>
|
||||
<module>slf4j-jdk14</module>
|
||||
<module>slf4j-jdk-platform-logging</module>
|
||||
<module>slf4j-log4j12</module>
|
||||
<module>slf4j-reload4j</module>
|
||||
<module>slf4j-ext</module>
|
||||
<module>jcl-over-slf4j</module>
|
||||
<module>log4j-over-slf4j</module>
|
||||
<module>jul-to-slf4j</module>
|
||||
<module>osgi-over-slf4j</module>
|
||||
<module>integration</module>
|
||||
<module>slf4j-site</module>
|
||||
<module>slf4j-migrator</module>
|
||||
<module>slf4j-migrator</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
|
@ -97,363 +64,181 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.cal10n</groupId>
|
||||
<artifactId>cal10n-api</artifactId>
|
||||
<version>${cal10n.version}</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk-platform-logging</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>osgi-over-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
<repository>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
|
||||
</distributionManagement>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>ceki</id>
|
||||
<name>Ceki Gulcu</name>
|
||||
<email>ceki@qos.ch</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>2.10</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
<version>1.14</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
<artifactId>java16</artifactId>
|
||||
<version>1.0</version>
|
||||
</signature>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-toolchains-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>toolchain</id>
|
||||
<goals>
|
||||
<goal>toolchain</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<configuration>
|
||||
<toolchains>
|
||||
<jdk>
|
||||
<version>9</version>
|
||||
</jdk>
|
||||
<verbose>true</verbose>
|
||||
<skippedModules>
|
||||
slf4j-jdk-platform-logging,slf4j-migrator,osgi-over-slf4j
|
||||
</skippedModules>
|
||||
<detectLinks>true</detectLinks>
|
||||
<doctitle>SLF4J project modules ${project.version}</doctitle>
|
||||
<windowtitle>SLF4J javadoc</windowtitle>
|
||||
<bottom><![CDATA[Copyright © 2005-{currentYear} QOS.CH Sarl. All rights reserved]]></bottom>
|
||||
<linksource>true</linksource>
|
||||
<additionalOptions>
|
||||
<additionalOption>-Xdoclint:none</additionalOption>
|
||||
</additionalOptions>
|
||||
<groups>
|
||||
<group>
|
||||
<title>SLF4J API packages</title>
|
||||
<packages>org.slf4j:org.slf4j.spi:org.slf4j.event:org.slf4j.helpers</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>slf4j-simple package</title>
|
||||
<packages>org.slf4j.simple</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>slf4j-nop package</title>
|
||||
<packages>org.slf4j.nop</packages>
|
||||
</group>
|
||||
|
||||
|
||||
<group>
|
||||
<title>slf4j-jdk14 package</title>
|
||||
<packages>org.slf4j.jul</packages>
|
||||
</group>
|
||||
|
||||
|
||||
<group>
|
||||
<title>slf4j-reload4j package</title>
|
||||
<packages>org.slf4j.reload4j</packages>
|
||||
</group>
|
||||
|
||||
|
||||
<group>
|
||||
<title>SLF4J extensions</title>
|
||||
<packages>
|
||||
org.slf4j.cal10n:org.slf4j.profiler:org.slf4j.ext:org.slf4j.instrumentation:org.slf4j.agent
|
||||
</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>Jakarta Commons Logging packages</title>
|
||||
<packages>org.apache.commons.*</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>java.util.logging (JUL) to SLF4J bridge</title>
|
||||
<packages>org.slf4j.bridge</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>log4j-over-slf4j redirection</title>
|
||||
<packages>org.apache.log4j:org.apache.log4j.*</packages>
|
||||
</group>
|
||||
</groups>
|
||||
|
||||
<jdk>
|
||||
<version>1.6</version>
|
||||
</jdk>
|
||||
</toolchains>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${compiler-plugin.version}</version>
|
||||
<executions>
|
||||
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<jdkToolchain>
|
||||
<version>[6, )</version>
|
||||
</jdkToolchain>
|
||||
<source>${jdk.version}</source>
|
||||
<target>${jdk.version}</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>module-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<jdkToolchain>
|
||||
<version>[9, )</version>
|
||||
</jdkToolchain>
|
||||
<release>9</release>
|
||||
<compileSourceRoots>
|
||||
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
|
||||
</compileSourceRoots>
|
||||
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/9</outputDirectory>
|
||||
<compilerArgs>
|
||||
<arg>--patch-module</arg>
|
||||
<arg>${module-name}=${project.build.outputDirectory}</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>${central-publishing-maven-plugin.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
||||
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Multi-Release>true</Multi-Release>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
<skipIfEmpty>true</skipIfEmpty>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<forkCount>2C</forkCount>
|
||||
<reuseForks>false</reuseForks>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
<excludeArtifacts>integration</excludeArtifacts>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/source.xml</descriptor>
|
||||
</descriptors>
|
||||
<finalName>slf4j-${project.version}</finalName>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<outputDirectory>target/site/dist/</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- as suggested in http://jira.qos.ch/browse/SLF4J-143 -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>parse-version</id>
|
||||
<goals>
|
||||
<goal>parse-version</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ====== site plugin ===== -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>${maven-site-plugin.version}</version>
|
||||
<configuration>
|
||||
<reportPlugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<javadocDir>target/site/apidocs/</javadocDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${javadoc-plugin.version}</version>
|
||||
<configuration>
|
||||
<linkJavadoc>true</linkJavadoc>
|
||||
<linksource>true</linksource>
|
||||
<aggregate>true</aggregate>
|
||||
<excludePackageNames>org.slf4j.migrator:org.slf4j.migrator.*</excludePackageNames>
|
||||
<sourceFileExcludes>
|
||||
<sourceFileExclude>**/module-info.java</sourceFileExclude>
|
||||
</sourceFileExcludes>
|
||||
|
||||
<links>
|
||||
<link>
|
||||
http://java.sun.com/j2se/1.5.0/docs/api
|
||||
</link>
|
||||
</links>
|
||||
<groups>
|
||||
<group>
|
||||
<title>SLF4J packages</title>
|
||||
<packages>org.slf4j:org.slf4j.*</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>SLF4J extensions</title>
|
||||
<packages>
|
||||
org.slf4j.cal10n:org.slf4j.profiler:org.slf4j.ext:org.slf4j.instrumentation:org.slf4j.agent
|
||||
</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>Jakarta Commons Logging packages</title>
|
||||
<packages>org.apache.commons.*</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>java.util.logging (JUL) to SLF4J bridge</title>
|
||||
<packages>org.slf4j.bridge</packages>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<title>Apache log4j</title>
|
||||
<packages>org.apache.log4j:org.apache.log4j.*</packages>
|
||||
</group>
|
||||
</groups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</reportPlugins>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>skipTests</id>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>javadocjar</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${javadoc.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sourceFileExcludes>
|
||||
<sourceFileExclude>**/module-info.java</sourceFileExclude>
|
||||
</sourceFileExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>license</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-license-plugin</groupId>
|
||||
<artifactId>maven-license-plugin</artifactId>
|
||||
<configuration>
|
||||
<header>src/main/licenseHeader.txt</header>
|
||||
<quiet>false</quiet>
|
||||
<failIfMissing>true</failIfMissing>
|
||||
<aggregate>true</aggregate>
|
||||
<includes>
|
||||
<include>src/**/*.java</include>
|
||||
</includes>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<useDefaultMapping>true</useDefaultMapping>
|
||||
<properties>
|
||||
<year>1999</year>
|
||||
</properties>
|
||||
<headerDefinitions>
|
||||
<headerDefinition>src/main/javadocHeaders.xml</headerDefinition>
|
||||
</headerDefinitions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>mc-release</id>
|
||||
<name>Local Maven repository of releases</name>
|
||||
<url>http://mc-repo.googlecode.com/svn/maven2/releases</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>sign-artifacts</id>
|
||||
|
|
@ -476,62 +261,6 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>travis</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.TRAVIS</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-toolchains-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>toolchain</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache-snapshot-repo</id>
|
||||
<name>apache-snapshot-repo</name>
|
||||
<url>https://repository.apache.org/content/groups/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<site>
|
||||
<id>qos_ch</id>
|
||||
<url>scp://yvo.qos.ch/var/www/www.slf4j.org/htdocs/</url>
|
||||
</site>
|
||||
|
||||
<repository>
|
||||
<!--<id>pixie</id>-->
|
||||
<!--<url>scp://pixie.qos.ch/var/mvnrepo/</url>-->
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
41
release.sh
41
release.sh
|
|
@ -1,10 +1,18 @@
|
|||
|
||||
# Javadoc
|
||||
|
||||
#JDK8 - mvn site:site
|
||||
#rscpSLF4J apidocs/
|
||||
|
||||
# JDK 11+
|
||||
# adding the following
|
||||
#mvn -Ddoclint=none -Dadditionalparam=-Xdoclint:none javadoc:aggregate
|
||||
|
||||
|
||||
#mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${VERSION_NUMBER}
|
||||
|
||||
MVN='/java/maven-3.5.2//bin/mvn'
|
||||
|
||||
PASS=$1
|
||||
echo $PASS
|
||||
|
||||
function checkExit(){
|
||||
if test "$?" != "0"; then
|
||||
echo Command $1 exited with abnormal status
|
||||
|
|
@ -21,7 +29,7 @@ function echoRunAndCheck () { # echo and then run the command
|
|||
then
|
||||
echo Failed command: $1
|
||||
exit 1;
|
||||
else echo Succussful run: $1
|
||||
else echo Successful run: $1
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -29,17 +37,26 @@ echoRunAndCheck "$MVN clean"
|
|||
|
||||
echoRunAndCheck "$MVN install"
|
||||
|
||||
echoRunAndCheck "$MVN site:site"
|
||||
#echoRunAndCheck "$MVN site:site"
|
||||
|
||||
#echoRunAndCheck "$MVN javadoc:aggregate"
|
||||
|
||||
#echoRunAndCheck "$MVN jxr:aggregate"
|
||||
|
||||
|
||||
echoRunAndCheck "$MVN assembly:single"
|
||||
if [ ! -z "$PASS" ]
|
||||
then
|
||||
# WARNING deploying without cleaning may leave stale MANIFEST files
|
||||
export GPG_TTY=$(tty)
|
||||
echoRunAndCheck "$MVN deploy -P javadocjar,sign-artifacts"
|
||||
fi
|
||||
|
||||
echoRunAndCheck "$MVN deploy -P javadocjar,sign-artifacts -Dgpg.passphrase=$PASS"
|
||||
|
||||
#$MVN site:deploy -N # with Java 8!!!
|
||||
#checkExit "mvn site:deploy -N"
|
||||
git tag -m "tagging" -a v_${VERSION_NUMBER}
|
||||
git push --tags
|
||||
|
||||
#git tag -m "tagging" -a v_${VERSION_NUMBER}
|
||||
#git push --tags
|
||||
#Update release version and add next version on jira
|
||||
|
||||
#release version and add next version on jira
|
||||
|
||||
|
||||
echo Full Success
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2007 QOS.ch
|
||||
Copyright (c) 2004-2023 QOS.ch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.8.0-beta4</version>
|
||||
<version>2.0.19-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
@ -21,7 +22,7 @@
|
|||
<properties>
|
||||
<module-name>org.slf4j</module-name>
|
||||
</properties>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
@ -41,17 +42,38 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-test-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>org.slf4j.spi;version="${range;[===,+);${version_cleanup;${project.version}}}"</Import-Package>
|
||||
<!-- Export the client/user package of slf4j-api version 1 to make the slf4j-api bundle in version 2 usable for bundles that only import slf4j-1.x -->
|
||||
<_exportcontents><![CDATA[
|
||||
*,\
|
||||
org.slf4j;version="${latest.1.version}",\
|
||||
org.slf4j.helpers;version="${latest.1.version}"
|
||||
]]></_exportcontents>
|
||||
<Require-Capability><![CDATA[
|
||||
osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))",
|
||||
osgi.serviceloader;filter:="(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)";osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider"
|
||||
]]></Require-Capability>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ package org.slf4j;
|
|||
* instances by name.
|
||||
*
|
||||
* <p>Most users retrieve {@link Logger} instances through the static
|
||||
* {@link LoggerFactory#getLogger(String)} method. An instance of of this
|
||||
* {@link LoggerFactory#getLogger(String)} method. An instance of this
|
||||
* interface is bound internally with {@link LoggerFactory} class at
|
||||
* compile time.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2004-2011 QOS.ch
|
||||
* Copyright (c) 2004-2022 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
|
@ -25,12 +25,29 @@
|
|||
|
||||
package org.slf4j;
|
||||
|
||||
import static org.slf4j.event.EventConstants.DEBUG_INT;
|
||||
import static org.slf4j.event.EventConstants.ERROR_INT;
|
||||
import static org.slf4j.event.EventConstants.INFO_INT;
|
||||
import static org.slf4j.event.EventConstants.TRACE_INT;
|
||||
import static org.slf4j.event.EventConstants.WARN_INT;
|
||||
import static org.slf4j.event.Level.DEBUG;
|
||||
import static org.slf4j.event.Level.ERROR;
|
||||
import static org.slf4j.event.Level.INFO;
|
||||
import static org.slf4j.event.Level.TRACE;
|
||||
import static org.slf4j.event.Level.WARN;
|
||||
|
||||
import org.slf4j.event.Level;
|
||||
import org.slf4j.helpers.CheckReturnValue;
|
||||
import org.slf4j.spi.DefaultLoggingEventBuilder;
|
||||
import org.slf4j.spi.LoggingEventBuilder;
|
||||
import org.slf4j.spi.NOPLoggingEventBuilder;
|
||||
|
||||
/**
|
||||
* The org.slf4j.Logger interface is the main user entry point of SLF4J API.
|
||||
* It is expected that logging takes place through concrete implementations
|
||||
* of this interface.
|
||||
* <p/>
|
||||
* <h3>Typical usage pattern:</h3>
|
||||
*
|
||||
* <H3>Typical usage pattern:</H3>
|
||||
* <pre>
|
||||
* import org.slf4j.Logger;
|
||||
* import org.slf4j.LoggerFactory;
|
||||
|
|
@ -45,26 +62,29 @@ package org.slf4j;
|
|||
* oldT = t;
|
||||
* t = temperature;
|
||||
* <span style="color:green">logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);</span>
|
||||
* if(temperature.intValue() > 50) {
|
||||
* if (temperature.intValue() > 50) {
|
||||
* <span style="color:green">logger.info("Temperature has risen above 50 degrees.");</span>
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Be sure to read the FAQ entry relating to <a href="../../../faq.html#logging_performance">parameterized
|
||||
* <p>Note that version 2.0 of the SLF4J API introduces a <a href="../../../manual.html#fluent">fluent api</a>,
|
||||
* the most significant API change to occur in the last 20 years.
|
||||
*
|
||||
* <p>Be sure to read the FAQ entry relating to <a href="../../../faq.html#logging_performance">parameterized
|
||||
* logging</a>. Note that logging statements can be parameterized in
|
||||
* <a href="../../../faq.html#paramException">presence of an exception/throwable</a>.
|
||||
*
|
||||
* <p>Once you are comfortable using loggers, i.e. instances of this interface, consider using
|
||||
* <a href="MDC.html">MDC</a> as well as <a href="Marker.html">Markers</a>.</p>
|
||||
* <a href="MDC.html">MDC</a> as well as <a href="Marker.html">Markers</a>.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface Logger {
|
||||
|
||||
/**
|
||||
* Case insensitive String constant used to retrieve the name of the root logger.
|
||||
* Case-insensitive String constant used to retrieve the name of the root logger.
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
|
|
@ -76,6 +96,70 @@ public interface Logger {
|
|||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger implementation.
|
||||
* This default implementation always returns a new instance of {@link DefaultLoggingEventBuilder}.</p>
|
||||
* <p></p>
|
||||
* <p>This method is intended to be used by logging systems implementing the SLF4J API and <b>not</b>
|
||||
* by end users.</p>
|
||||
* <p></p>
|
||||
* <p>Also note that a {@link LoggingEventBuilder} instance should be built for all levels,
|
||||
* independently of the level argument. In other words, this method is an <b>unconditional</b>
|
||||
* constructor for the {@link LoggingEventBuilder} appropriate for this logger implementation.</p>
|
||||
* <p></p>
|
||||
* @param level desired level for the event builder
|
||||
* @return a new {@link LoggingEventBuilder} instance as appropriate for <b>this</b> logger
|
||||
* @since 2.0
|
||||
*/
|
||||
default public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
|
||||
return new DefaultLoggingEventBuilder(this, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
|
||||
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
|
||||
* a {@link NOPLoggingEventBuilder} is returned.
|
||||
*
|
||||
*
|
||||
* @param level desired level for the event builder
|
||||
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atLevel(Level level) {
|
||||
if (isEnabledForLevel(level)) {
|
||||
return makeLoggingEventBuilder(level);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this Logger is enabled for a given {@link Level}.
|
||||
*
|
||||
* @param level
|
||||
* @return true if enabled, false otherwise.
|
||||
*/
|
||||
default public boolean isEnabledForLevel(Level level) {
|
||||
int levelInt = level.toInt();
|
||||
switch (levelInt) {
|
||||
case (TRACE_INT):
|
||||
return isTraceEnabled();
|
||||
case (DEBUG_INT):
|
||||
return isDebugEnabled();
|
||||
case (INFO_INT):
|
||||
return isInfoEnabled();
|
||||
case (WARN_INT):
|
||||
return isWarnEnabled();
|
||||
case (ERROR_INT):
|
||||
return isErrorEnabled();
|
||||
default:
|
||||
throw new IllegalArgumentException("Level [" + level + "] not recognized.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the logger instance enabled for the TRACE level?
|
||||
*
|
||||
|
|
@ -96,9 +180,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the TRACE level according to the specified format
|
||||
* and argument.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the TRACE level. </p>
|
||||
* is disabled for the TRACE level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg the argument
|
||||
|
|
@ -109,9 +193,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the TRACE level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the TRACE level. </p>
|
||||
* is disabled for the TRACE level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg1 the first argument
|
||||
|
|
@ -123,12 +207,12 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the TRACE level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous string concatenation when the logger
|
||||
* is disabled for the TRACE level. However, this variant incurs the hidden
|
||||
* (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
|
||||
* even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and
|
||||
* {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p>
|
||||
* {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arguments a list of 3 or more arguments
|
||||
|
|
@ -158,6 +242,21 @@ public interface Logger {
|
|||
*/
|
||||
public boolean isTraceEnabled(Marker marker);
|
||||
|
||||
/**
|
||||
* Entry point for fluent-logging for {@link org.slf4j.event.Level#TRACE} level.
|
||||
*
|
||||
* @return LoggingEventBuilder instance as appropriate for level TRACE
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atTrace() {
|
||||
if (isTraceEnabled()) {
|
||||
return makeLoggingEventBuilder(TRACE);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with the specific Marker at the TRACE level.
|
||||
*
|
||||
|
|
@ -232,9 +331,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the DEBUG level according to the specified format
|
||||
* and argument.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the DEBUG level. </p>
|
||||
* is disabled for the DEBUG level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg the argument
|
||||
|
|
@ -244,9 +343,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the DEBUG level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the DEBUG level. </p>
|
||||
* is disabled for the DEBUG level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg1 the first argument
|
||||
|
|
@ -257,13 +356,13 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the DEBUG level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous string concatenation when the logger
|
||||
* is disabled for the DEBUG level. However, this variant incurs the hidden
|
||||
* (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
|
||||
* even if this logger is disabled for DEBUG. The variants taking
|
||||
* {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two}
|
||||
* arguments exist solely in order to avoid this hidden cost.</p>
|
||||
* arguments exist solely in order to avoid this hidden cost.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arguments a list of 3 or more arguments
|
||||
|
|
@ -340,6 +439,21 @@ public interface Logger {
|
|||
*/
|
||||
public void debug(Marker marker, String msg, Throwable t);
|
||||
|
||||
/**
|
||||
* Entry point for fluent-logging for {@link org.slf4j.event.Level#DEBUG} level.
|
||||
*
|
||||
* @return LoggingEventBuilder instance as appropriate for level DEBUG
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atDebug() {
|
||||
if (isDebugEnabled()) {
|
||||
return makeLoggingEventBuilder(DEBUG);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the logger instance enabled for the INFO level?
|
||||
*
|
||||
|
|
@ -358,9 +472,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the INFO level according to the specified format
|
||||
* and argument.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the INFO level. </p>
|
||||
* is disabled for the INFO level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg the argument
|
||||
|
|
@ -370,9 +484,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the INFO level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the INFO level. </p>
|
||||
* is disabled for the INFO level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg1 the first argument
|
||||
|
|
@ -383,13 +497,13 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the INFO level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous string concatenation when the logger
|
||||
* is disabled for the INFO level. However, this variant incurs the hidden
|
||||
* (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
|
||||
* even if this logger is disabled for INFO. The variants taking
|
||||
* {@link #info(String, Object) one} and {@link #info(String, Object, Object) two}
|
||||
* arguments exist solely in order to avoid this hidden cost.</p>
|
||||
* arguments exist solely in order to avoid this hidden cost.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arguments a list of 3 or more arguments
|
||||
|
|
@ -410,7 +524,8 @@ public interface Logger {
|
|||
* data is also taken into consideration.
|
||||
*
|
||||
* @param marker The marker data to take into consideration
|
||||
* @return true if this logger is warn enabled, false otherwise
|
||||
* @return true if this Logger is enabled for the INFO level,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isInfoEnabled(Marker marker);
|
||||
|
||||
|
|
@ -465,6 +580,21 @@ public interface Logger {
|
|||
*/
|
||||
public void info(Marker marker, String msg, Throwable t);
|
||||
|
||||
/**
|
||||
* Entry point for fluent-logging for {@link org.slf4j.event.Level#INFO} level.
|
||||
*
|
||||
* @return LoggingEventBuilder instance as appropriate for level INFO
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atInfo() {
|
||||
if (isInfoEnabled()) {
|
||||
return makeLoggingEventBuilder(INFO);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the logger instance enabled for the WARN level?
|
||||
*
|
||||
|
|
@ -483,9 +613,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the WARN level according to the specified format
|
||||
* and argument.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the WARN level. </p>
|
||||
* is disabled for the WARN level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg the argument
|
||||
|
|
@ -495,13 +625,13 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the WARN level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous string concatenation when the logger
|
||||
* is disabled for the WARN level. However, this variant incurs the hidden
|
||||
* (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
|
||||
* even if this logger is disabled for WARN. The variants taking
|
||||
* {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two}
|
||||
* arguments exist solely in order to avoid this hidden cost.</p>
|
||||
* arguments exist solely in order to avoid this hidden cost.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arguments a list of 3 or more arguments
|
||||
|
|
@ -511,9 +641,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the WARN level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the WARN level. </p>
|
||||
* is disabled for the WARN level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg1 the first argument
|
||||
|
|
@ -591,6 +721,21 @@ public interface Logger {
|
|||
*/
|
||||
public void warn(Marker marker, String msg, Throwable t);
|
||||
|
||||
/**
|
||||
* Entry point for fluent-logging for {@link org.slf4j.event.Level#WARN} level.
|
||||
*
|
||||
* @return LoggingEventBuilder instance as appropriate for level WARN
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atWarn() {
|
||||
if (isWarnEnabled()) {
|
||||
return makeLoggingEventBuilder(WARN);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the logger instance enabled for the ERROR level?
|
||||
*
|
||||
|
|
@ -609,9 +754,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the ERROR level according to the specified format
|
||||
* and argument.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the ERROR level. </p>
|
||||
* is disabled for the ERROR level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg the argument
|
||||
|
|
@ -621,9 +766,9 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the ERROR level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous object creation when the logger
|
||||
* is disabled for the ERROR level. </p>
|
||||
* is disabled for the ERROR level.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arg1 the first argument
|
||||
|
|
@ -634,13 +779,13 @@ public interface Logger {
|
|||
/**
|
||||
* Log a message at the ERROR level according to the specified format
|
||||
* and arguments.
|
||||
* <p/>
|
||||
*
|
||||
* <p>This form avoids superfluous string concatenation when the logger
|
||||
* is disabled for the ERROR level. However, this variant incurs the hidden
|
||||
* (and relatively small) cost of creating an <code>Object[]</code> before invoking the method,
|
||||
* even if this logger is disabled for ERROR. The variants taking
|
||||
* {@link #error(String, Object) one} and {@link #error(String, Object, Object) two}
|
||||
* arguments exist solely in order to avoid this hidden cost.</p>
|
||||
* arguments exist solely in order to avoid this hidden cost.
|
||||
*
|
||||
* @param format the format string
|
||||
* @param arguments a list of 3 or more arguments
|
||||
|
|
@ -718,4 +863,19 @@ public interface Logger {
|
|||
*/
|
||||
public void error(Marker marker, String msg, Throwable t);
|
||||
|
||||
/**
|
||||
* Entry point for fluent-logging for {@link org.slf4j.event.Level#ERROR} level.
|
||||
*
|
||||
* @return LoggingEventBuilder instance as appropriate for level ERROR
|
||||
* @since 2.0
|
||||
*/
|
||||
@CheckReturnValue
|
||||
default public LoggingEventBuilder atError() {
|
||||
if (isErrorEnabled()) {
|
||||
return makeLoggingEventBuilder(ERROR);
|
||||
} else {
|
||||
return NOPLoggingEventBuilder.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,54 +25,56 @@
|
|||
package org.slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.event.SubstituteLoggingEvent;
|
||||
import org.slf4j.helpers.NOPServiceProvider;
|
||||
import org.slf4j.helpers.SubstituteServiceProvider;
|
||||
import org.slf4j.helpers.NOP_FallbackServiceProvider;
|
||||
import org.slf4j.helpers.Reporter;
|
||||
import org.slf4j.helpers.SubstituteLogger;
|
||||
|
||||
import org.slf4j.helpers.SubstituteServiceProvider;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
import org.slf4j.spi.SLF4JServiceProvider;
|
||||
|
||||
/**
|
||||
* The <code>LoggerFactory</code> is a utility class producing Loggers for
|
||||
* various logging APIs, most notably for log4j, logback and JDK 1.4 logging.
|
||||
* Other implementations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
|
||||
* {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <code>LoggerFactory</code> is essentially a wrapper around an
|
||||
* {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
|
||||
* compile time.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* various logging APIs, e.g. logback, reload4j, log4j and JDK 1.4 logging.
|
||||
* Other implementations such as {@link org.slf4j.helpers.NOPLogger NOPLogger} and
|
||||
* SimpleLogger are also supported.
|
||||
*
|
||||
* <p><code>LoggerFactory</code> is essentially a wrapper around an
|
||||
* {@link ILoggerFactory} instance provided by a {@link SLF4JServiceProvider}.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in <code>LoggerFactory</code> are static.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Alexander Dorokhine
|
||||
* @author Robert Elliot
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class LoggerFactory {
|
||||
|
||||
static final String CODES_PREFIX = "http://www.slf4j.org/codes.html";
|
||||
static final String CODES_PREFIX = "https://www.slf4j.org/codes.html";
|
||||
|
||||
static final String NO_PROVIDERS_URL = CODES_PREFIX + "#noProviders";
|
||||
static final String IGNORED_BINDINGS_URL = CODES_PREFIX + "#ignoredBindings";
|
||||
|
||||
static final String NO_STATICLOGGERBINDER_URL = CODES_PREFIX + "#StaticLoggerBinder";
|
||||
|
||||
static final String MULTIPLE_BINDINGS_URL = CODES_PREFIX + "#multiple_bindings";
|
||||
static final String NULL_LF_URL = CODES_PREFIX + "#null_LF";
|
||||
static final String VERSION_MISMATCH = CODES_PREFIX + "#version_mismatch";
|
||||
static final String SUBSTITUTE_LOGGER_URL = CODES_PREFIX + "#substituteLogger";
|
||||
static final String LOGGER_NAME_MISMATCH_URL = CODES_PREFIX + "#loggerNameMismatch";
|
||||
|
|
@ -82,6 +84,16 @@ public final class LoggerFactory {
|
|||
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also "
|
||||
+ UNSUCCESSFUL_INIT_URL;
|
||||
|
||||
static final String CONNECTED_WITH_MSG = "Connected with provider of type [";
|
||||
|
||||
/**
|
||||
* System property for explicitly setting the provider class. If set and the provider could be instantiated,
|
||||
* then the service loading mechanism will be bypassed.
|
||||
*
|
||||
* @since 2.0.9
|
||||
*/
|
||||
static final public String PROVIDER_PROPERTY_KEY = "slf4j.provider";
|
||||
|
||||
static final int UNINITIALIZED = 0;
|
||||
static final int ONGOING_INITIALIZATION = 1;
|
||||
static final int FAILED_INITIALIZATION = 2;
|
||||
|
|
@ -90,7 +102,7 @@ public final class LoggerFactory {
|
|||
|
||||
static volatile int INITIALIZATION_STATE = UNINITIALIZED;
|
||||
static final SubstituteServiceProvider SUBST_PROVIDER = new SubstituteServiceProvider();
|
||||
static final NOPServiceProvider NOP_FALLBACK_FACTORY = new NOPServiceProvider();
|
||||
static final NOP_FallbackServiceProvider NOP_FALLBACK_SERVICE_PROVIDER = new NOP_FallbackServiceProvider();
|
||||
|
||||
// Support for detecting mismatched logger names.
|
||||
static final String DETECT_LOGGER_NAME_MISMATCH_PROPERTY = "slf4j.detectLoggerNameMismatch";
|
||||
|
|
@ -100,23 +112,57 @@ public final class LoggerFactory {
|
|||
|
||||
static volatile SLF4JServiceProvider PROVIDER;
|
||||
|
||||
private static List<SLF4JServiceProvider> findServiceProviders() {
|
||||
ServiceLoader<SLF4JServiceProvider> serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class);
|
||||
List<SLF4JServiceProvider> providerList = new ArrayList<SLF4JServiceProvider>();
|
||||
for (SLF4JServiceProvider provider : serviceLoader) {
|
||||
providerList.add(provider);
|
||||
// Package access for tests
|
||||
static List<SLF4JServiceProvider> findServiceProviders() {
|
||||
List<SLF4JServiceProvider> providerList = new ArrayList<>();
|
||||
|
||||
// retain behaviour similar to that of 1.7 series and earlier. More specifically, use the class loader that
|
||||
// loaded the present class to search for services
|
||||
final ClassLoader classLoaderOfLoggerFactory = LoggerFactory.class.getClassLoader();
|
||||
|
||||
SLF4JServiceProvider explicitProvider = loadExplicitlySpecified(classLoaderOfLoggerFactory);
|
||||
if(explicitProvider != null) {
|
||||
providerList.add(explicitProvider);
|
||||
return providerList;
|
||||
}
|
||||
|
||||
|
||||
ServiceLoader<SLF4JServiceProvider> serviceLoader = getServiceLoader(classLoaderOfLoggerFactory);
|
||||
|
||||
Iterator<SLF4JServiceProvider> iterator = serviceLoader.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
safelyInstantiate(providerList, iterator);
|
||||
}
|
||||
return providerList;
|
||||
}
|
||||
|
||||
private static ServiceLoader<SLF4JServiceProvider> getServiceLoader(final ClassLoader classLoaderOfLoggerFactory) {
|
||||
ServiceLoader<SLF4JServiceProvider> serviceLoader;
|
||||
SecurityManager securityManager = System.getSecurityManager();
|
||||
if(securityManager == null) {
|
||||
serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory);
|
||||
} else {
|
||||
final PrivilegedAction<ServiceLoader<SLF4JServiceProvider>> action = () -> ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory);
|
||||
serviceLoader = AccessController.doPrivileged(action);
|
||||
}
|
||||
return serviceLoader;
|
||||
}
|
||||
|
||||
private static void safelyInstantiate(List<SLF4JServiceProvider> providerList, Iterator<SLF4JServiceProvider> iterator) {
|
||||
try {
|
||||
SLF4JServiceProvider provider = iterator.next();
|
||||
providerList.add(provider);
|
||||
} catch (ServiceConfigurationError e) {
|
||||
Reporter.error("A service provider failed to instantiate:\n" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It is LoggerFactory's responsibility to track version changes and manage
|
||||
* the compatibility list.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* It is assumed that all versions in the 1.6 are mutually compatible.
|
||||
* <p>
|
||||
*/
|
||||
static private final String[] API_COMPATIBILITY_LIST = new String[] { "1.8", "1.7" };
|
||||
static private final String[] API_COMPATIBILITY_LIST = new String[] { "2.0" };
|
||||
|
||||
// private constructor prevents instantiation
|
||||
private LoggerFactory() {
|
||||
|
|
@ -124,13 +170,13 @@ public final class LoggerFactory {
|
|||
|
||||
/**
|
||||
* Force LoggerFactory to consider itself uninitialized.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* This method is intended to be called by classes (in the same package) for
|
||||
* testing purposes. This method is internal. It can be modified, renamed or
|
||||
* removed at any time without notice.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* You are strongly discouraged from calling this method in production code.
|
||||
*/
|
||||
static void reset() {
|
||||
|
|
@ -149,51 +195,86 @@ public final class LoggerFactory {
|
|||
List<SLF4JServiceProvider> providersList = findServiceProviders();
|
||||
reportMultipleBindingAmbiguity(providersList);
|
||||
if (providersList != null && !providersList.isEmpty()) {
|
||||
PROVIDER = providersList.get(0);
|
||||
PROVIDER.initialize();
|
||||
INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION;
|
||||
PROVIDER = providersList.get(0);
|
||||
earlyBindMDCAdapter();
|
||||
// SLF4JServiceProvider.initialize() is intended to be called here and nowhere else.
|
||||
PROVIDER.initialize();
|
||||
INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION;
|
||||
reportActualBinding(providersList);
|
||||
fixSubstituteLoggers();
|
||||
replayEvents();
|
||||
// release all resources in SUBST_FACTORY
|
||||
SUBST_PROVIDER.getSubstituteLoggerFactory().clear();
|
||||
} else {
|
||||
INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION;
|
||||
Util.report("No SLF4J providers were found.");
|
||||
Util.report("Defaulting to no-operation (NOP) logger implementation");
|
||||
Util.report("See " + NO_PROVIDERS_URL + " for further details.");
|
||||
Reporter.warn("No SLF4J providers were found.");
|
||||
Reporter.warn("Defaulting to no-operation (NOP) logger implementation");
|
||||
Reporter.warn("See " + NO_PROVIDERS_URL + " for further details.");
|
||||
|
||||
Set<URL> staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet();
|
||||
reportIgnoredStaticLoggerBinders(staticLoggerBinderPathSet);
|
||||
}
|
||||
postBindCleanUp();
|
||||
} catch (Exception e) {
|
||||
failedBinding(e);
|
||||
throw new IllegalStateException("Unexpected initialization failure", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of PROVIDER.getMDCAdapter() can be null while PROVIDER has not yet initialized.
|
||||
*
|
||||
* However, SLF4JServiceProvider implementations are expected to initialize their internal
|
||||
* MDCAdapter field in their constructor or on field declaration.
|
||||
*/
|
||||
private static void earlyBindMDCAdapter() {
|
||||
MDCAdapter mdcAdapter = PROVIDER.getMDCAdapter();
|
||||
if(mdcAdapter != null) {
|
||||
MDC.setMDCAdapter(mdcAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
static SLF4JServiceProvider loadExplicitlySpecified(ClassLoader classLoader) {
|
||||
String explicitlySpecified = System.getProperty(PROVIDER_PROPERTY_KEY);
|
||||
if (null == explicitlySpecified || explicitlySpecified.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String message = String.format("Attempting to load provider \"%s\" specified via \"%s\" system property", explicitlySpecified, PROVIDER_PROPERTY_KEY);
|
||||
Reporter.info(message);
|
||||
Class<?> clazz = classLoader.loadClass(explicitlySpecified);
|
||||
Constructor<?> constructor = clazz.getConstructor();
|
||||
Object provider = constructor.newInstance();
|
||||
return (SLF4JServiceProvider) provider;
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
String message = String.format("Failed to instantiate the specified SLF4JServiceProvider (%s)", explicitlySpecified);
|
||||
Reporter.error(message, e);
|
||||
return null;
|
||||
} catch (ClassCastException e) {
|
||||
String message = String.format("Specified SLF4JServiceProvider (%s) does not implement SLF4JServiceProvider interface", explicitlySpecified);
|
||||
Reporter.error(message, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportIgnoredStaticLoggerBinders(Set<URL> staticLoggerBinderPathSet) {
|
||||
if (staticLoggerBinderPathSet.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Util.report("Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.");
|
||||
Reporter.warn("Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.");
|
||||
|
||||
for (URL path : staticLoggerBinderPathSet) {
|
||||
Util.report("Ignoring binding found at [" + path + "]");
|
||||
Reporter.warn("Ignoring binding found at [" + path + "]");
|
||||
}
|
||||
Util.report("See " + IGNORED_BINDINGS_URL + " for an explanation.");
|
||||
|
||||
Reporter.warn("See " + IGNORED_BINDINGS_URL + " for an explanation.");
|
||||
|
||||
}
|
||||
|
||||
// We need to use the name of the StaticLoggerBinder class, but we can't
|
||||
// reference the class itself.
|
||||
private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
private static final String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
|
||||
static Set<URL> findPossibleStaticLoggerBinderPathSet() {
|
||||
// use Set instead of list in order to deal with bug #138
|
||||
// LinkedHashSet appropriate here because it preserves insertion order
|
||||
// during iteration
|
||||
Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>();
|
||||
Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<>();
|
||||
try {
|
||||
ClassLoader loggerFactoryClassLoader = LoggerFactory.class.getClassLoader();
|
||||
Enumeration<URL> paths;
|
||||
|
|
@ -207,11 +288,18 @@ public final class LoggerFactory {
|
|||
staticLoggerBinderPathSet.add(path);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Util.report("Error getting resources from path", ioe);
|
||||
Reporter.error("Error getting resources from path", ioe);
|
||||
}
|
||||
return staticLoggerBinderPathSet;
|
||||
}
|
||||
|
||||
private static void postBindCleanUp() {
|
||||
fixSubstituteLoggers();
|
||||
replayEvents();
|
||||
// release all resources in SUBST_FACTORY
|
||||
SUBST_PROVIDER.getSubstituteLoggerFactory().clear();
|
||||
}
|
||||
|
||||
private static void fixSubstituteLoggers() {
|
||||
synchronized (SUBST_PROVIDER) {
|
||||
SUBST_PROVIDER.getSubstituteLoggerFactory().postInitialization();
|
||||
|
|
@ -225,7 +313,7 @@ public final class LoggerFactory {
|
|||
|
||||
static void failedBinding(Throwable t) {
|
||||
INITIALIZATION_STATE = FAILED_INITIALIZATION;
|
||||
Util.report("Failed to instantiate SLF4J LoggerFactory", t);
|
||||
Reporter.error("Failed to instantiate SLF4J LoggerFactory", t);
|
||||
}
|
||||
|
||||
private static void replayEvents() {
|
||||
|
|
@ -233,7 +321,7 @@ public final class LoggerFactory {
|
|||
final int queueSize = queue.size();
|
||||
int count = 0;
|
||||
final int maxDrain = 128;
|
||||
List<SubstituteLoggingEvent> eventList = new ArrayList<SubstituteLoggingEvent>(maxDrain);
|
||||
List<SubstituteLoggingEvent> eventList = new ArrayList<>(maxDrain);
|
||||
while (true) {
|
||||
int numDrained = queue.drainTo(eventList, maxDrain);
|
||||
if (numDrained == 0)
|
||||
|
|
@ -270,29 +358,31 @@ public final class LoggerFactory {
|
|||
if (substLogger.isDelegateNOP()) {
|
||||
// nothing to do
|
||||
} else if (substLogger.isDelegateEventAware()) {
|
||||
substLogger.log(event);
|
||||
if(substLogger.isEnabledForLevel(event.getLevel())) {
|
||||
substLogger.log(event);
|
||||
}
|
||||
} else {
|
||||
Util.report(loggerName);
|
||||
Reporter.warn(loggerName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void emitSubstitutionWarning() {
|
||||
Util.report("The following set of substitute loggers may have been accessed");
|
||||
Util.report("during the initialization phase. Logging calls during this");
|
||||
Util.report("phase were not honored. However, subsequent logging calls to these");
|
||||
Util.report("loggers will work as normally expected.");
|
||||
Util.report("See also " + SUBSTITUTE_LOGGER_URL);
|
||||
Reporter.warn("The following set of substitute loggers may have been accessed");
|
||||
Reporter.warn("during the initialization phase. Logging calls during this");
|
||||
Reporter.warn("phase were not honored. However, subsequent logging calls to these");
|
||||
Reporter.warn("loggers will work as normally expected.");
|
||||
Reporter.warn("See also " + SUBSTITUTE_LOGGER_URL);
|
||||
}
|
||||
|
||||
private static void emitReplayWarning(int eventCount) {
|
||||
Util.report("A number (" + eventCount + ") of logging calls during the initialization phase have been intercepted and are");
|
||||
Util.report("now being replayed. These are subject to the filtering rules of the underlying logging system.");
|
||||
Util.report("See also " + REPLAY_URL);
|
||||
Reporter.warn("A number (" + eventCount + ") of logging calls during the initialization phase have been intercepted and are");
|
||||
Reporter.warn("now being replayed. These are subject to the filtering rules of the underlying logging system.");
|
||||
Reporter.warn("See also " + REPLAY_URL);
|
||||
}
|
||||
|
||||
private final static void versionSanityCheck() {
|
||||
try {
|
||||
String requested = PROVIDER.getRequesteApiVersion();
|
||||
String requested = PROVIDER.getRequestedApiVersion();
|
||||
|
||||
boolean match = false;
|
||||
for (String aAPI_COMPATIBILITY_LIST : API_COMPATIBILITY_LIST) {
|
||||
|
|
@ -301,18 +391,13 @@ public final class LoggerFactory {
|
|||
}
|
||||
}
|
||||
if (!match) {
|
||||
Util.report("The requested version " + requested + " by your slf4j binding is not compatible with "
|
||||
Reporter.warn("The requested version " + requested + " by your slf4j provider is not compatible with "
|
||||
+ Arrays.asList(API_COMPATIBILITY_LIST).toString());
|
||||
Util.report("See " + VERSION_MISMATCH + " for further details.");
|
||||
Reporter.warn("See " + VERSION_MISMATCH + " for further details.");
|
||||
}
|
||||
} catch (java.lang.NoSuchFieldError nsfe) {
|
||||
// given our large user base and SLF4J's commitment to backward
|
||||
// compatibility, we cannot cry here. Only for implementations
|
||||
// which willingly declare a REQUESTED_API_VERSION field do we
|
||||
// emit compatibility warnings.
|
||||
} catch (Throwable e) {
|
||||
// we should never reach here
|
||||
Util.report("Unexpected problem occured during version sanity check", e);
|
||||
Reporter.error("Unexpected problem occurred during version sanity check", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,29 +408,36 @@ public final class LoggerFactory {
|
|||
/**
|
||||
* Prints a warning message on the console if multiple bindings were found
|
||||
* on the class path. No reporting is done otherwise.
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static void reportMultipleBindingAmbiguity(List<SLF4JServiceProvider> providerList) {
|
||||
if (isAmbiguousProviderList(providerList)) {
|
||||
Util.report("Class path contains multiple SLF4J providers.");
|
||||
Reporter.warn("Class path contains multiple SLF4J providers.");
|
||||
for (SLF4JServiceProvider provider : providerList) {
|
||||
Util.report("Found provider [" + provider + "]");
|
||||
Reporter.warn("Found provider [" + provider + "]");
|
||||
}
|
||||
Util.report("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
|
||||
Reporter.warn("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportActualBinding(List<SLF4JServiceProvider> providerList) {
|
||||
// binderPathSet can be null under Android
|
||||
if (!providerList.isEmpty() && isAmbiguousProviderList(providerList)) {
|
||||
Util.report("Actual provider is of type [" + providerList.get(0) + "]");
|
||||
// impossible since a provider has been found
|
||||
if (providerList.isEmpty()) {
|
||||
throw new IllegalStateException("No providers were found which is impossible after successful initialization.");
|
||||
}
|
||||
|
||||
if (isAmbiguousProviderList(providerList)) {
|
||||
Reporter.info("Actual provider is of type [" + providerList.get(0) + "]");
|
||||
} else {
|
||||
SLF4JServiceProvider provider = providerList.get(0);
|
||||
Reporter.debug(CONNECTED_WITH_MSG + provider.getClass().getName() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a logger named according to the name parameter using the
|
||||
* statically bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* The name of the logger.
|
||||
* @return logger
|
||||
|
|
@ -358,20 +450,20 @@ public final class LoggerFactory {
|
|||
/**
|
||||
* Return a logger named corresponding to the class passed as parameter,
|
||||
* using the statically bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In case the the <code>clazz</code> parameter differs from the name of the
|
||||
* In case the <code>clazz</code> parameter differs from the name of the
|
||||
* caller as computed internally by SLF4J, a logger name mismatch warning
|
||||
* will be printed but only if the
|
||||
* <code>slf4j.detectLoggerNameMismatch</code> system property is set to
|
||||
* true. By default, this property is not set and no warnings will be
|
||||
* printed even in case of a logger name mismatch.
|
||||
*
|
||||
*
|
||||
* @param clazz
|
||||
* the returned logger will be named after clazz
|
||||
* @return logger
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @see <a
|
||||
* href="http://www.slf4j.org/codes.html#loggerNameMismatch">Detected
|
||||
* logger name mismatch</a>
|
||||
|
|
@ -381,9 +473,9 @@ public final class LoggerFactory {
|
|||
if (DETECT_LOGGER_NAME_MISMATCH) {
|
||||
Class<?> autoComputedCallingClass = Util.getCallingClass();
|
||||
if (autoComputedCallingClass != null && nonMatchingClasses(clazz, autoComputedCallingClass)) {
|
||||
Util.report(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", logger.getName(),
|
||||
Reporter.warn(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", logger.getName(),
|
||||
autoComputedCallingClass.getName()));
|
||||
Util.report("See " + LOGGER_NAME_MISMATCH_URL + " for an explanation");
|
||||
Reporter.warn("See " + LOGGER_NAME_MISMATCH_URL + " for an explanation");
|
||||
}
|
||||
}
|
||||
return logger;
|
||||
|
|
@ -395,10 +487,10 @@ public final class LoggerFactory {
|
|||
|
||||
/**
|
||||
* Return the {@link ILoggerFactory} instance in use.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>
|
||||
* <p>
|
||||
* ILoggerFactory instance is bound with this class at compile time.
|
||||
*
|
||||
*
|
||||
* @return the ILoggerFactory instance in use
|
||||
*/
|
||||
public static ILoggerFactory getILoggerFactory() {
|
||||
|
|
@ -424,7 +516,7 @@ public final class LoggerFactory {
|
|||
case SUCCESSFUL_INITIALIZATION:
|
||||
return PROVIDER;
|
||||
case NOP_FALLBACK_INITIALIZATION:
|
||||
return NOP_FALLBACK_FACTORY;
|
||||
return NOP_FALLBACK_SERVICE_PROVIDER;
|
||||
case FAILED_INITIALIZATION:
|
||||
throw new IllegalStateException(UNSUCCESSFUL_INIT_MSG);
|
||||
case ONGOING_INITIALIZATION:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,35 @@
|
|||
/**
|
||||
* Copyright (c) 2004-2021 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
package org.slf4j;
|
||||
|
||||
/**
|
||||
* All methods in this class are reserved for internal use, for testing purposes.
|
||||
* <p/>
|
||||
* <p/>They can can be modified, renamed or removed at any time without notice.
|
||||
* <p/>
|
||||
* You are strongly discouraged calling any of the methods of this class.
|
||||
*
|
||||
* <p>They can be modified, renamed or removed at any time without notice.
|
||||
*
|
||||
* <p>You are strongly discouraged calling any of the methods of this class.
|
||||
*
|
||||
* @since 1.8.0
|
||||
*
|
||||
|
|
@ -14,7 +38,7 @@ package org.slf4j;
|
|||
public class LoggerFactoryFriend {
|
||||
|
||||
/*
|
||||
* Force LoggerFactory to consider itself uninitialized. <p/>
|
||||
* Force LoggerFactory to consider itself uninitialized.
|
||||
*/
|
||||
static public void reset() {
|
||||
LoggerFactory.reset();
|
||||
|
|
@ -23,7 +47,7 @@ public class LoggerFactoryFriend {
|
|||
/**
|
||||
* Set LoggerFactory.DETECT_LOGGER_NAME_MISMATCH variable.
|
||||
*
|
||||
* @param enabled
|
||||
* @param enabled a boolean
|
||||
*/
|
||||
public static void setDetectLoggerNameMismatch(boolean enabled) {
|
||||
LoggerFactory.DETECT_LOGGER_NAME_MISMATCH = enabled;
|
||||
|
|
|
|||
|
|
@ -25,11 +25,10 @@
|
|||
package org.slf4j;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Deque;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.helpers.BasicMDCAdapter;
|
||||
import org.slf4j.helpers.NOPMDCAdapter;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.helpers.*;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
import org.slf4j.spi.SLF4JServiceProvider;
|
||||
|
||||
|
|
@ -64,8 +63,9 @@ import org.slf4j.spi.SLF4JServiceProvider;
|
|||
public class MDC {
|
||||
|
||||
static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA";
|
||||
private static final String MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE = "MDCAdapter cannot be null. See also " + NULL_MDCA_URL;
|
||||
static final String NO_STATIC_MDC_BINDER_URL = "http://www.slf4j.org/codes.html#no_static_mdc_binder";
|
||||
static MDCAdapter mdcAdapter;
|
||||
static MDCAdapter MDC_ADAPTER;
|
||||
|
||||
/**
|
||||
* An adapter to remove the key when done.
|
||||
|
|
@ -85,14 +85,30 @@ public class MDC {
|
|||
private MDC() {
|
||||
}
|
||||
|
||||
static {
|
||||
private static MDCAdapter getMDCAdapterGivenByProvider() {
|
||||
SLF4JServiceProvider provider = LoggerFactory.getProvider();
|
||||
if (provider != null) {
|
||||
mdcAdapter = provider.getMDCAdapter();
|
||||
if(provider != null) {
|
||||
// If you wish to change the mdc adapter, setting the MDC.MDCAdapter variable might be insufficient.
|
||||
// Keep in mind that the provider *might* perform additional internal mdcAdapter assignments that
|
||||
// you would also need to replicate/adapt.
|
||||
|
||||
// obtain and attach the MDCAdapter from the provider
|
||||
|
||||
final MDCAdapter anAdapter = provider.getMDCAdapter();
|
||||
emitTemporaryMDCAdapterWarningIfNeeded(provider);
|
||||
return anAdapter;
|
||||
} else {
|
||||
Util.report("Failed to find provider.");
|
||||
Util.report("Defaulting to no-operation MDCAdapter implementation.");
|
||||
mdcAdapter = new NOPMDCAdapter();
|
||||
Reporter.error("Failed to find provider.");
|
||||
Reporter.error("Defaulting to no-operation MDCAdapter implementation.");
|
||||
return new NOPMDCAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
private static void emitTemporaryMDCAdapterWarningIfNeeded(SLF4JServiceProvider provider) {
|
||||
boolean isSubstitute = provider instanceof SubstituteServiceProvider;
|
||||
if(isSubstitute) {
|
||||
Reporter.info("Temporary mdcAdapter given by SubstituteServiceProvider.");
|
||||
Reporter.info("This mdcAdapter will be replaced after backend initialization has completed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,10 +131,10 @@ public class MDC {
|
|||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
if (getMDCAdapter() == null) {
|
||||
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
|
||||
}
|
||||
mdcAdapter.put(key, val);
|
||||
getMDCAdapter().put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -161,7 +177,7 @@ public class MDC {
|
|||
* <p>
|
||||
* This method delegates all work to the MDC of the underlying logging system.
|
||||
*
|
||||
* @param key
|
||||
* @param key a key
|
||||
* @return the string value identified by the <code>key</code> parameter.
|
||||
* @throws IllegalArgumentException
|
||||
* in case the "key" parameter is null
|
||||
|
|
@ -171,10 +187,8 @@ public class MDC {
|
|||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.get(key);
|
||||
mdcAdapterNullCheck();
|
||||
return getMDCAdapter().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -183,7 +197,7 @@ public class MDC {
|
|||
* cannot be null. This method does nothing if there is no previous value
|
||||
* associated with <code>key</code>.
|
||||
*
|
||||
* @param key
|
||||
* @param key a key
|
||||
* @throws IllegalArgumentException
|
||||
* in case the "key" parameter is null
|
||||
*/
|
||||
|
|
@ -192,20 +206,16 @@ public class MDC {
|
|||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.remove(key);
|
||||
mdcAdapterNullCheck();
|
||||
getMDCAdapter().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC of the underlying implementation.
|
||||
*/
|
||||
public static void clear() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.clear();
|
||||
mdcAdapterNullCheck();
|
||||
getMDCAdapter().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,10 +226,8 @@ public class MDC {
|
|||
* @since 1.5.1
|
||||
*/
|
||||
public static Map<String, String> getCopyOfContextMap() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.getCopyOfContextMap();
|
||||
mdcAdapterNullCheck();
|
||||
return getMDCAdapter().getCopyOfContextMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -227,25 +235,86 @@ public class MDC {
|
|||
* then copying the map passed as parameter. The context map passed as
|
||||
* parameter must only contain keys and values of type String.
|
||||
*
|
||||
* Null valued argument is allowed (since SLF4J version 2.0.0).
|
||||
*
|
||||
* @param contextMap
|
||||
* must contain only keys and values of type String
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static void setContextMap(Map<String, String> contextMap) {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.setContextMap(contextMap);
|
||||
mdcAdapterNullCheck();
|
||||
getMDCAdapter().setContextMap(contextMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MDCAdapter instance currently in use.
|
||||
*
|
||||
*
|
||||
* Since 2.0.17, if the MDCAdapter instance is null, then this method set it to use
|
||||
* the adapter returned by the SLF4JProvider. However, in the vast majority of cases
|
||||
* the MDCAdapter will be set earlier (during initialization) by {@link LoggerFactory}.
|
||||
*
|
||||
* @return the MDcAdapter instance currently in use.
|
||||
* @since 1.4.2
|
||||
*/
|
||||
public static MDCAdapter getMDCAdapter() {
|
||||
return mdcAdapter;
|
||||
if(MDC_ADAPTER == null) {
|
||||
MDC_ADAPTER = getMDCAdapterGivenByProvider();
|
||||
}
|
||||
return MDC_ADAPTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set MDCAdapter instance to use.
|
||||
*
|
||||
* @since 2.0.17
|
||||
*/
|
||||
static void setMDCAdapter(MDCAdapter anMDCAdapter) {
|
||||
if(anMDCAdapter == null) {
|
||||
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
|
||||
}
|
||||
MDC_ADAPTER = anMDCAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a value into the deque(stack) referenced by 'key'.
|
||||
*
|
||||
* @param key identifies the appropriate stack
|
||||
* @param value the value to push into the stack
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static public void pushByKey(String key, String value) {
|
||||
mdcAdapterNullCheck();
|
||||
getMDCAdapter().pushByKey(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the <b>stack</b> referenced by 'key' and return the value possibly null.
|
||||
*
|
||||
* @param key identifies the deque(stack)
|
||||
* @return the value just popped. May be null/
|
||||
* @since 2.0.0
|
||||
*/
|
||||
static public String popByKey(String key) {
|
||||
mdcAdapterNullCheck();
|
||||
return getMDCAdapter().popByKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the <b>deque(stack)</b> referenced by 'key'. May be null.
|
||||
*
|
||||
* @param key identifies the stack
|
||||
* @return copy of stack referenced by 'key'. May be null.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public Deque<String> getCopyOfDequeByKey(String key) {
|
||||
mdcAdapterNullCheck();
|
||||
return getMDCAdapter().getCopyOfDequeByKey(key);
|
||||
}
|
||||
|
||||
private static void mdcAdapterNullCheck() {
|
||||
if (getMDCAdapter() == null) {
|
||||
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,16 @@ import java.util.Iterator;
|
|||
|
||||
/**
|
||||
* Markers are named objects used to enrich log statements. Conforming logging
|
||||
* system Implementations of SLF4J determine how information conveyed by markers
|
||||
* are used, if at all. In particular, many conforming logging systems ignore
|
||||
* marker data.
|
||||
*
|
||||
* <p>
|
||||
* Markers can contain references to other markers, which in turn may contain
|
||||
* references of their own.
|
||||
*
|
||||
* system implementations of SLF4J should determine how information conveyed by
|
||||
* any markers are used, if at all. Many conforming logging systems ignore marker
|
||||
* data entirely.
|
||||
*
|
||||
* <p>Markers can contain references to nested markers, which in turn may
|
||||
* contain references of their own. Note that the fluent API (new in 2.0) allows adding
|
||||
* multiple markers to a logging statement. It is often preferable to use
|
||||
* multiple markers instead of nested markers.
|
||||
* </p>
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface Marker extends Serializable {
|
||||
|
|
@ -60,7 +62,11 @@ public interface Marker extends Serializable {
|
|||
|
||||
/**
|
||||
* Add a reference to another Marker.
|
||||
*
|
||||
*
|
||||
* <p>Note that the fluent API allows adding multiple markers to a logging statement.
|
||||
* It is often preferable to use multiple markers instead of nested markers.
|
||||
* </p>
|
||||
*
|
||||
* @param reference
|
||||
* a reference to another marker
|
||||
* @throws IllegalArgumentException
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
package org.slf4j;
|
||||
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
import org.slf4j.helpers.Reporter;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.spi.SLF4JServiceProvider;
|
||||
|
||||
|
|
@ -47,16 +48,14 @@ public class MarkerFactory {
|
|||
private MarkerFactory() {
|
||||
}
|
||||
|
||||
|
||||
// this is where the binding happens
|
||||
static {
|
||||
SLF4JServiceProvider provider = LoggerFactory.getProvider();
|
||||
if (provider != null) {
|
||||
provider.initialize();
|
||||
MARKER_FACTORY = provider.getMarkerFactory();
|
||||
} else {
|
||||
Util.report("Failed to find provider");
|
||||
Util.report("Defaulting to BasicMarkerFactory.");
|
||||
Reporter.error("Failed to find provider");
|
||||
Reporter.error("Defaulting to BasicMarkerFactory.");
|
||||
MARKER_FACTORY = new BasicMarkerFactory();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
package org.slf4j.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* A default implementation of {@link LoggingEvent}.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DefaultLoggingEvent implements LoggingEvent {
|
||||
|
||||
Logger logger;
|
||||
Level level;
|
||||
|
||||
String message;
|
||||
List<Marker> markers;
|
||||
List<Object> arguments;
|
||||
List<KeyValuePair> keyValuePairs;
|
||||
|
||||
Throwable throwable;
|
||||
String threadName;
|
||||
long timeStamp;
|
||||
|
||||
String callerBoundary;
|
||||
|
||||
public DefaultLoggingEvent(Level level, Logger logger) {
|
||||
this.logger = logger;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void addMarker(Marker marker) {
|
||||
if (markers == null) {
|
||||
markers = new ArrayList<>(2);
|
||||
}
|
||||
markers.add(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Marker> getMarkers() {
|
||||
return markers;
|
||||
}
|
||||
|
||||
public void addArgument(Object p) {
|
||||
getNonNullArguments().add(p);
|
||||
}
|
||||
|
||||
public void addArguments(Object... args) {
|
||||
getNonNullArguments().addAll(Arrays.asList(args));
|
||||
}
|
||||
|
||||
private List<Object> getNonNullArguments() {
|
||||
if (arguments == null) {
|
||||
arguments = new ArrayList<>(3);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArgumentArray() {
|
||||
if (arguments == null)
|
||||
return null;
|
||||
return arguments.toArray();
|
||||
}
|
||||
|
||||
public void addKeyValue(String key, Object value) {
|
||||
getNonnullKeyValuePairs().add(new KeyValuePair(key, value));
|
||||
}
|
||||
|
||||
private List<KeyValuePair> getNonnullKeyValuePairs() {
|
||||
if (keyValuePairs == null) {
|
||||
keyValuePairs = new ArrayList<>(4);
|
||||
}
|
||||
return keyValuePairs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValuePair> getKeyValuePairs() {
|
||||
return keyValuePairs;
|
||||
}
|
||||
|
||||
public void setThrowable(Throwable cause) {
|
||||
this.throwable = cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLoggerName() {
|
||||
return logger.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Throwable getThrowable() {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public String getThreadName() {
|
||||
return threadName;
|
||||
}
|
||||
|
||||
public long getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(long timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public void setCallerBoundary(String fqcn) {
|
||||
this.callerBoundary = fqcn;
|
||||
}
|
||||
|
||||
public String getCallerBoundary() {
|
||||
return callerBoundary;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,296 +0,0 @@
|
|||
package org.slf4j.event;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.helpers.SubstituteLogger;
|
||||
|
||||
public class EventRecodingLogger implements Logger {
|
||||
|
||||
String name;
|
||||
SubstituteLogger logger;
|
||||
Queue<SubstituteLoggingEvent> eventQueue;
|
||||
|
||||
public EventRecodingLogger(SubstituteLogger logger, Queue<SubstituteLoggingEvent> eventQueue) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
this.eventQueue = eventQueue;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private void recordEvent(Level level, String msg, Object[] args, Throwable throwable) {
|
||||
recordEvent(level, null, msg, args, throwable);
|
||||
}
|
||||
|
||||
private void recordEvent(Level level, Marker marker, String msg, Object[] args, Throwable throwable) {
|
||||
// System.out.println("recording logger:"+name+", msg:"+msg);
|
||||
SubstituteLoggingEvent loggingEvent = new SubstituteLoggingEvent();
|
||||
loggingEvent.setTimeStamp(System.currentTimeMillis());
|
||||
loggingEvent.setLevel(level);
|
||||
loggingEvent.setLogger(logger);
|
||||
loggingEvent.setLoggerName(name);
|
||||
loggingEvent.setMarker(marker);
|
||||
loggingEvent.setMessage(msg);
|
||||
loggingEvent.setArgumentArray(args);
|
||||
loggingEvent.setThrowable(throwable);
|
||||
loggingEvent.setThreadName(Thread.currentThread().getName());
|
||||
eventQueue.add(loggingEvent);
|
||||
}
|
||||
|
||||
public boolean isTraceEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void trace(String msg) {
|
||||
recordEvent(Level.TRACE, msg, null, null);
|
||||
}
|
||||
|
||||
public void trace(String format, Object arg) {
|
||||
recordEvent(Level.TRACE, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void trace(String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.TRACE, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void trace(String format, Object... arguments) {
|
||||
recordEvent(Level.TRACE, format, arguments, null);
|
||||
}
|
||||
|
||||
public void trace(String msg, Throwable t) {
|
||||
recordEvent(Level.TRACE, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isTraceEnabled(Marker marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg) {
|
||||
recordEvent(Level.TRACE, marker, msg, null, null);
|
||||
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg) {
|
||||
recordEvent(Level.TRACE, marker, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.TRACE, marker, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object... argArray) {
|
||||
recordEvent(Level.TRACE, marker, format, argArray, null);
|
||||
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg, Throwable t) {
|
||||
recordEvent(Level.TRACE, marker, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void debug(String msg) {
|
||||
recordEvent(Level.DEBUG, msg, null, null);
|
||||
}
|
||||
|
||||
public void debug(String format, Object arg) {
|
||||
recordEvent(Level.DEBUG, format, new Object[] { arg }, null);
|
||||
|
||||
}
|
||||
|
||||
public void debug(String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.DEBUG, format, new Object[] { arg1, arg2 }, null);
|
||||
|
||||
}
|
||||
|
||||
public void debug(String format, Object... arguments) {
|
||||
recordEvent(Level.DEBUG, format, arguments, null);
|
||||
}
|
||||
|
||||
public void debug(String msg, Throwable t) {
|
||||
recordEvent(Level.DEBUG, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled(Marker marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg) {
|
||||
recordEvent(Level.DEBUG, marker, msg, null, null);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg) {
|
||||
recordEvent(Level.DEBUG, marker, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.DEBUG, marker, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object... arguments) {
|
||||
recordEvent(Level.DEBUG, marker, format, arguments, null);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg, Throwable t) {
|
||||
recordEvent(Level.DEBUG, marker, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void info(String msg) {
|
||||
recordEvent(Level.INFO, msg, null, null);
|
||||
}
|
||||
|
||||
public void info(String format, Object arg) {
|
||||
recordEvent(Level.INFO, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void info(String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.INFO, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void info(String format, Object... arguments) {
|
||||
recordEvent(Level.INFO, format, arguments, null);
|
||||
}
|
||||
|
||||
public void info(String msg, Throwable t) {
|
||||
recordEvent(Level.INFO, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled(Marker marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg) {
|
||||
recordEvent(Level.INFO, marker, msg, null, null);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg) {
|
||||
recordEvent(Level.INFO, marker, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.INFO, marker, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object... arguments) {
|
||||
recordEvent(Level.INFO, marker, format, arguments, null);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg, Throwable t) {
|
||||
recordEvent(Level.INFO, marker, msg, null, t);
|
||||
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void warn(String msg) {
|
||||
recordEvent(Level.WARN, msg, null, null);
|
||||
}
|
||||
|
||||
public void warn(String format, Object arg) {
|
||||
recordEvent(Level.WARN, format, new Object[] { arg }, null);
|
||||
|
||||
}
|
||||
|
||||
public void warn(String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.WARN, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void warn(String format, Object... arguments) {
|
||||
recordEvent(Level.WARN, format, arguments, null);
|
||||
}
|
||||
|
||||
public void warn(String msg, Throwable t) {
|
||||
recordEvent(Level.WARN, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled(Marker marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg) {
|
||||
recordEvent(Level.WARN, marker, msg, null, null);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg) {
|
||||
recordEvent(Level.WARN, format, new Object[] { arg }, null);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.WARN, marker, format, new Object[] { arg1, arg2 }, null);
|
||||
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object... arguments) {
|
||||
recordEvent(Level.WARN, marker, format, arguments, null);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg, Throwable t) {
|
||||
recordEvent(Level.WARN, marker, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isErrorEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void error(String msg) {
|
||||
recordEvent(Level.ERROR, msg, null, null);
|
||||
}
|
||||
|
||||
public void error(String format, Object arg) {
|
||||
recordEvent(Level.ERROR, format, new Object[] { arg }, null);
|
||||
|
||||
}
|
||||
|
||||
public void error(String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.ERROR, format, new Object[] { arg1, arg2 }, null);
|
||||
|
||||
}
|
||||
|
||||
public void error(String format, Object... arguments) {
|
||||
recordEvent(Level.ERROR, format, arguments, null);
|
||||
|
||||
}
|
||||
|
||||
public void error(String msg, Throwable t) {
|
||||
recordEvent(Level.ERROR, msg, null, t);
|
||||
}
|
||||
|
||||
public boolean isErrorEnabled(Marker marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg) {
|
||||
recordEvent(Level.ERROR, marker, msg, null, null);
|
||||
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg) {
|
||||
recordEvent(Level.ERROR, marker, format, new Object[] { arg }, null);
|
||||
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg1, Object arg2) {
|
||||
recordEvent(Level.ERROR, marker, format, new Object[] { arg1, arg2 }, null);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object... arguments) {
|
||||
recordEvent(Level.ERROR, marker, format, arguments, null);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg, Throwable t) {
|
||||
recordEvent(Level.ERROR, marker, msg, null, t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package org.slf4j.event;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.helpers.LegacyAbstractLogger;
|
||||
import org.slf4j.helpers.SubstituteLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used to record events during the initialization phase of the
|
||||
* underlying logging framework. It is called by {@link SubstituteLogger}.
|
||||
*
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Wessel van Norel
|
||||
*
|
||||
*/
|
||||
public class EventRecordingLogger extends LegacyAbstractLogger {
|
||||
|
||||
private static final long serialVersionUID = -176083308134819629L;
|
||||
|
||||
String name;
|
||||
SubstituteLogger logger;
|
||||
Queue<SubstituteLoggingEvent> eventQueue;
|
||||
|
||||
// as an event recording logger we have no choice but to record all events
|
||||
final static boolean RECORD_ALL_EVENTS = true;
|
||||
|
||||
public EventRecordingLogger(SubstituteLogger logger, Queue<SubstituteLoggingEvent> eventQueue) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
this.eventQueue = eventQueue;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isTraceEnabled() {
|
||||
return RECORD_ALL_EVENTS;
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled() {
|
||||
return RECORD_ALL_EVENTS;
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled() {
|
||||
return RECORD_ALL_EVENTS;
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled() {
|
||||
return RECORD_ALL_EVENTS;
|
||||
}
|
||||
|
||||
public boolean isErrorEnabled() {
|
||||
return RECORD_ALL_EVENTS;
|
||||
}
|
||||
|
||||
// WARNING: this method assumes that any throwable is properly extracted
|
||||
protected void handleNormalizedLoggingCall(Level level, Marker marker, String msg, Object[] args, Throwable throwable) {
|
||||
SubstituteLoggingEvent loggingEvent = new SubstituteLoggingEvent();
|
||||
loggingEvent.setTimeStamp(System.currentTimeMillis());
|
||||
loggingEvent.setLevel(level);
|
||||
loggingEvent.setLogger(logger);
|
||||
loggingEvent.setLoggerName(name);
|
||||
if (marker != null) {
|
||||
loggingEvent.addMarker(marker);
|
||||
}
|
||||
loggingEvent.setMessage(msg);
|
||||
loggingEvent.setThreadName(Thread.currentThread().getName());
|
||||
|
||||
loggingEvent.setArgumentArray(args);
|
||||
loggingEvent.setThrowable(throwable);
|
||||
|
||||
eventQueue.add(loggingEvent);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFullyQualifiedCallerName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package org.slf4j.event;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KeyValuePair {
|
||||
|
||||
public final String key;
|
||||
public final Object value;
|
||||
|
||||
public KeyValuePair(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(key) + "=\"" + String.valueOf(value) +"\"";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
KeyValuePair that = (KeyValuePair) o;
|
||||
return Objects.equals(key, that.key) && Objects.equals(value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,16 +7,18 @@ import static org.slf4j.event.EventConstants.TRACE_INT;
|
|||
import static org.slf4j.event.EventConstants.WARN_INT;
|
||||
|
||||
/**
|
||||
* SLF4J's internal representation of Level.
|
||||
*
|
||||
* @author ceki
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.7.15
|
||||
*/
|
||||
public enum Level {
|
||||
|
||||
ERROR(ERROR_INT, "ERROR"), WARN(WARN_INT, "WARN"), INFO(INFO_INT, "INFO"), DEBUG(DEBUG_INT, "DEBUG"), TRACE(TRACE_INT, "TRACE");
|
||||
|
||||
private int levelInt;
|
||||
private String levelStr;
|
||||
private final int levelInt;
|
||||
private final String levelStr;
|
||||
|
||||
Level(int i, String s) {
|
||||
levelInt = i;
|
||||
|
|
@ -27,6 +29,23 @@ public enum Level {
|
|||
return levelInt;
|
||||
}
|
||||
|
||||
public static Level intToLevel(int levelInt) {
|
||||
switch (levelInt) {
|
||||
case (TRACE_INT):
|
||||
return TRACE;
|
||||
case (DEBUG_INT):
|
||||
return DEBUG;
|
||||
case (INFO_INT):
|
||||
return INFO;
|
||||
case (WARN_INT):
|
||||
return WARN;
|
||||
case (ERROR_INT):
|
||||
return ERROR;
|
||||
default:
|
||||
throw new IllegalArgumentException("Level integer [" + levelInt + "] not recognized.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this Level.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,28 +1,49 @@
|
|||
package org.slf4j.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* The minimal interface sufficient for the restitution of data passed
|
||||
* by the user to the SLF4J API.
|
||||
*
|
||||
* @author ceki
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.7.15
|
||||
*/
|
||||
public interface LoggingEvent {
|
||||
|
||||
Level getLevel();
|
||||
|
||||
Marker getMarker();
|
||||
|
||||
String getLoggerName();
|
||||
|
||||
String getMessage();
|
||||
|
||||
String getThreadName();
|
||||
List<Object> getArguments();
|
||||
|
||||
Object[] getArgumentArray();
|
||||
|
||||
long getTimeStamp();
|
||||
/**
|
||||
* List of markers in the event, might be null.
|
||||
* @return markers in the event, might be null.
|
||||
*/
|
||||
List<Marker> getMarkers();
|
||||
|
||||
List<KeyValuePair> getKeyValuePairs();
|
||||
|
||||
Throwable getThrowable();
|
||||
|
||||
long getTimeStamp();
|
||||
|
||||
String getThreadName();
|
||||
|
||||
/**
|
||||
* Returns the presumed caller boundary provided by the logging library (not the user of the library).
|
||||
* Null by default.
|
||||
*
|
||||
* @return presumed caller, null by default.
|
||||
*/
|
||||
default String getCallerBoundary() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue