差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
java:log4j [2022/02/04 16:00]
tony
java:log4j [2023/06/25 09:48] (目前版本)
行 1: 行 1:
-{{tag>​java log4j}} +{{tag>​java log4j log4j2}} 
-====== Log4j/Slf4j ======+====== Log4j/SLF4J ======
 Log4j是在開發Java程式時,會使用的logging套件之一。網路上已經可以找到許多配置說明,在這我只分享一些心得與遇到的問題。 Log4j是在開發Java程式時,會使用的logging套件之一。網路上已經可以找到許多配置說明,在這我只分享一些心得與遇到的問題。
 ===== Articles for Log4j 1.x ===== ===== Articles for Log4j 1.x =====
行 6: 行 6:
   * [[.:​log4j:​bridge|Bridge JUL to SLF4j]]   * [[.:​log4j:​bridge|Bridge JUL to SLF4j]]
   * [[.:​log4j:​extend_appender|Extend the appender]]   * [[.:​log4j:​extend_appender|Extend the appender]]
-===== Articles for Log4j 2.x ===== +==== Resource ====
-  * [[.:​log4j2:​ChangeLogLevelAtRuntime|Change log level at runtime]] +
-===== Resource ​=====+
   * [[http://​www.cnblogs.com/​Mainz/​p/​3628414.html|Log4j最佳实践]]   * [[http://​www.cnblogs.com/​Mainz/​p/​3628414.html|Log4j最佳实践]]
   * [[http://​www.blogjava.net/​wilesun/​archive/​2007/​10/​30/​156999.html|log4j的ConversionPattern参数的格式含义]]   * [[http://​www.blogjava.net/​wilesun/​archive/​2007/​10/​30/​156999.html|log4j的ConversionPattern参数的格式含义]]
行 14: 行 12:
   * [[https://​www.marcobehler.com/​guides/​a-guide-to-logging-in-java|A guide to logging in Java]]   * [[https://​www.marcobehler.com/​guides/​a-guide-to-logging-in-java|A guide to logging in Java]]
   * [[https://​javarevisited.blogspot.com/​2017/​04/​log4j-tips-use-mdc-or-mapped-dignostic-context-to-log-per-client-or-request.html|Log4j Tips : Use MDC or Mapped Dignostic Context to distinguish logging per Client or Request]]   * [[https://​javarevisited.blogspot.com/​2017/​04/​log4j-tips-use-mdc-or-mapped-dignostic-context-to-log-per-client-or-request.html|Log4j Tips : Use MDC or Mapped Dignostic Context to distinguish logging per Client or Request]]
 +===== Articles for Log4j 2.x =====
 +套用SLF4J+Log4j2最快的方法,就是套Log4j 2 SLF4J Binding,參考此[[https://​logging.apache.org/​log4j/​2.x/​log4j-slf4j-impl/​|連結]]。
 +  * [[.:​log4j2:​helloworld|Log4j2 - Hello World!]]
 +  * [[.:​log4j2:​indicateConfigurationFile|Indicate Log4j2 Configuration File]]
 +  * [[.:​log4j2:​mdc|MDC with Log4j2]]
 +  * [[.:​log4j2:​appenders|Log4j2 Appenders]]
 +  * [[.:​log4j2:​timeAndSizeRollingAppender|在Log4j2設定TimeAndSizeRollingAppender]]
 +  * [[.:​log4j2:​ChangeLogLevelAtRuntime|Change log level at runtime]]
 +  * [[.:​log4j2:​ReloadConfiguration|Reload Log4j configuration]]
 +==== Resource ====
   * [[https://​www.ithome.com.tw/​voice/​117126|哪來這麼多日誌程式庫?]] log library相關歷史   * [[https://​www.ithome.com.tw/​voice/​117126|哪來這麼多日誌程式庫?]] log library相關歷史
 +  * [[https://​codertw.com/​伺服器/​164013/#​outline__3_1|Log4j1 升級 Log4j2 實戰]]
 +  * [[https://​logging.apache.org/​log4j/​2.x/​manual/​migration.html|Migrating from Log4j 1.x to 2.x]]
 +  * [[https://​codertw.com/​%E4%BC%BA%E6%9C%8D%E5%99%A8/​157515/​|MDC to ThreadContext]] 可以參考log4j-1.2-api bridge做法:​[[https://​github.com/​apache/​logging-log4j2/​blob/​f72100df0decc9bda96b4d769822c4e48b2848fc/​log4j-1.2-api/​src/​main/​java/​org/​apache/​log4j/​MDC.java|link]]
 +  * [[https://​stackoverflow.com/​questions/​31384939/​log4j2-including-library-name-in-stacktrace|讓exception stacktrace沒有library路徑]]
 +  * [[https://​levelup.gitconnected.com/​logging-best-practices-mdc-ingestion-and-scale-78319cee7b96|Logging Best Practices — MDC, Ingestion and Scale]] *
  
 =====    ===== =====    =====