Log4j learning notes

xiaoxiao2021-03-06  60

Three Basic Concept: Category: you instantiate a category instance, you can call its various logging methods (such as debug, info, warn, error, fatal) to send your message to log Appender:.. Different destinations the message is appended for example , File, Console, JDBC, ETC. Layout: in Which Format You Want Your Logging Message Will Be Appended. SimpleLayout, Htmllayout, Patternlayout

A File Named Log4j.Properties Should Be create and Placed In Same ClassPath With your application Which Invokes The Log API.

Patterns Associated with MDC: org.apache.log4j.mdc -static void Put (String Key, Object O) - MDC.PUT ("Server", "Jaguar"); - MDC.PUT ("Test" , "MyContext"); in patientLayout =% D% x {server}% x {test} // be careful, x is case sensitive. -Static void remove (String Key)

转载请注明原文地址:https://www.9cbs.com/read-112223.html

New Post(0)