Log4j nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Log4j nyob rau lub caij nplooj ntoos hlav yog dab tsi?

Video: Log4j nyob rau lub caij nplooj ntoos hlav yog dab tsi?

Video: Log4j nyob rau lub caij nplooj ntoos hlav yog dab tsi?
Video: Vergiss Google Analytics, so geht Tracking (ohne Cookie-Banner) 2024, Kaum ib hlis
Anonim

log4j yog ib tug nrov thiab dav-siv logging moj khaum rau Java txoj kev loj hlob. Nws yooj yim heev rau kev teeb tsa thiab siv lub log4j mechanism hauv a Caij nplooj ntoos hlav Mvc daim ntawv thov. Nyob rau hauv no nyeem, kuv yuav qhia koj yuav ua li cas los mus siv lub logging functionality nrog lub Caij nplooj ntoos hlav Mvc framework.

Raws li txoj cai, kev siv logger nyob rau lub caij nplooj ntoo hlav yog dab tsi?

Caij nplooj ntoos hlav khau raj - Kev sau npe . Caij nplooj ntoos hlav khau raj siv Apache Commons kaw lus rau tag nrho cov internal kaw lus . Caij nplooj ntoos hlav Boot's default configurations muab kev txhawb nqa rau cov siv ntawm Java Util Kev sau npe , Log4j2, thiab Logback. Siv cov no, peb tuaj yeem teeb tsa lub console kaw lus zoo li cov ntaub ntawv kaw lus.

Qhov thib ob, Logback Spring XML yog dab tsi? Logback Configuration los ntawm External File Raws li kuv tau hais ua ntej, Logback txhawb kev nkag siab txog kev teeb tsa los ntawm XML thiab Groovy configuration files. Hauv ib Caij nplooj ntoos hlav Khau raj daim ntawv thov, koj tuaj yeem teev a Logback XML configuration file as logback . xml los yog logback - caij nplooj ntoos hlav . xml hauv qhov project classpath. xml ntaub ntawv.

Ib yam li ntawd, nws raug nug, log4j yog dab tsi?

log4j yog ib lub cuab yeej los pab tus programmer tso tawm cov ntawv teev lus rau ntau lub hom phiaj tso tawm. Thaum muaj teeb meem nrog daim ntawv thov, nws yog pab tau kom nkag mus kom qhov teeb meem tuaj yeem nyob. Nrog cog 4j nws yog muaj peev xwm ua kom nkag tau rau ntawm lub sijhawm khiav yam tsis tau hloov kho daim ntawv thov binary.

Vim li cas peb thiaj siv logger hauv Java?

1.1. Kev sau npe . Kev sau npe yog tus txheej txheem ntawm kev sau cov lus kaw thaum lub sijhawm ua tiav ntawm qhov program mus rau qhov chaw nruab nrab. Qhov no kaw lus tso cai koj ceeb toom thiab pheej ua yuam kev thiab ceeb toom cov lus nrog rau cov ntaub ntawv xov xwm (piv txwv li, runtime txheeb cais) kom cov lus tuaj yeem rov qab tau thiab tshuaj xyuas tom qab.

Pom zoo: