{"id":232567,"date":"2021-12-31T09:10:50","date_gmt":"2021-12-31T01:10:50","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=232567"},"modified":"2021-12-22T14:11:43","modified_gmt":"2021-12-22T06:11:43","slug":"spring-boot-log4j2","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/spring-boot-log4j2.html","title":{"rendered":"Spring Boot \u5e94\u5bf9 Log4j2 \u6ce8\u5165\u6f0f\u6d1e\u6307\u5357"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Log4J2\u6f0f\u6d1e\u6d89\u53ca\u7684\u5f71\u54cd\u592a\u5e7f\u4e86\uff0c\u6628\u5929\u53d1\u6587\u540e\u5f88\u591a\u7c89\u4e1d\u7559\u8a00\u95eeSpring Boot\u9879\u76ee\u662f\u5426\u53d7\u5230Log4J2\u6f0f\u6d1e\u5f71\u54cd\u3002Spring\u5b98\u65b9\u5df2\u7ecf\u5168\u9762\u8fdb\u884c\u4e86\u6392\u67e5\uff0c\u73b0\u5728\u5927\u5bb6\u53ef\u4ee5\u77e5\u9053\u8fd9\u4e9b\u4fe1\u606f\u548c\u5e94\u5bf9\u65b9\u6cd5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u9ed8\u8ba4\u914d\u7f6e\u4e0d\u53d7\u5f71\u54cd<\/strong><\/div>\n Spring Boot\u9ed8\u8ba4\u65e5\u5fd7\u7ec4\u4ef6\u662flogback\uff0c\u5f00\u53d1\u8005\u901a\u8fc7\u65e5\u5fd7\u95e8\u9762Slf4j\u8fdb\u884c\u96c6\u6210\u5bf9\u63a5\u3002Spring Boot \u7528\u6237\u53ea\u6709\u5728\u5c06\u9ed8\u8ba4\u65e5\u5fd7\u7cfb\u7edf\u5207\u6362\u5230 Log4J2 \u65f6\u624d\u4f1a\u53d7\u5230\u6b64\u6f0f\u6d1e\u7684\u5f71\u54cd\u3002Spring Boot\u5305\u542b\u7684log4j-to-slf4j\u548clog4j-api\u3001spring-boot-starter-logging\u4e0d\u80fd\u72ec\u7acb\u5229\u7528\u3002\u53ea\u6709log4j-core\u5728\u65e5\u5fd7\u6d88\u606f\u4e2d\u4f7f\u7528\u548c\u5305\u542b\u7528\u6237\u8f93\u5165\u7684\u5e94\u7528\u7a0b\u5e8f\u5bb9\u6613\u53d7\u5230\u653b\u51fb\u3002<\/p>\n \u4e5f\u5c31\u662f\u8bf4Spring Boot\u73b0\u5728\u5305\u542bLog4J2\u7684\u4f9d\u8d56\u53ea\u8981\u4f60\u4e0d\u542f\u7528\u662f\u4e0d\u4f1a\u89e6\u53d1\u6f0f\u6d1e\u7684\u3002<\/p>\n <\/p>\n \u4e0b\u7248\u672c\u66f4\u65b0\u8865\u4e01<\/strong><\/div>\n Spring Boot\u5c06\u57282021 \u5e74 12 \u6708 23 \u65e5\u540e\u53d1\u5e03\u7684 2.5.8 \u548c 2.6.2 \u7248\u672c\u5c06\u91c7\u7528\u6253\u4e86\u8865\u4e01\u7684Log4J v2.15.0\uff0c\u4f46\u7531\u4e8e\u8fd9\u662f\u4e00\u4e2a\u6781\u5176\u4e25\u91cd\u7684\u6f0f\u6d1e\uff0c\u4e00\u5b9a\u8981\u8986\u76d6\u6211\u4eec\u7684\u4f9d\u8d56\u9879\u7ba1\u7406\u5e76\u5c3d\u5feb\u5347\u7ea7\u60a8\u7684 Log4J2 \u4f9d\u8d56\u9879\u3002<\/p>\n Maven\u7528\u6237<\/strong><\/span><\/div>\n \u5bf9\u4e8e Maven \u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8986\u76d6\u81ea\u5df1\u9879\u76ee\u4e2dpom.xml\u7684\u7248\u672c\u53f7\u914d\u7f6e\u5c5e\u6027\u6765\u4fee\u6539\u8be5\u4f9d\u8d56\u7684\u7248\u672c\u53f7\u3002\u63d0\u5347Log4J2\u5230\u5b89\u5168\u7248\u672c\u53ea\u9700\u8981\uff1a<\/p>\n \r\n <properties> <\/span>\r\n <log4j2.version>2.15.0<\/log4j2.version> <\/span>\r\n <\/properties> <\/span>\r\n<\/pre>\n |