Advertisement

Advertisement

What is Logger? Types of Logger? Rolling Poicies of Logger. Various log levels in .net

What is Logger? Types of Logger? Rolling Poicies of Logger. Various log levels in .net


"logger" ek important concept hota hai, jo application ke debugging, monitoring, aur error tracking ke liye use hota hai.

Logger ek component hota hai jo application ke various parts se generate hote huye log messages ko record karta hai.

Ye messages typically information, warnings, errors, aur exceptions ko shamil karte hain. In log messages ki madad se developers application ke behavior aur performance ke saath sath issues ko track kar sakte hain.

.NET MVC me, aap different logging libraries aur tools ka use kar sakte hain, jaise ki:

1. NLog: NLog ek popular .NET logging library hai, jo configurable aur extensible hota hai. Iska use aap apne MVC application me log messages ko record karne ke liye kar sakte hain.

2. log4net: log4net bhi ek commonly used .NET logging framework hai, jo aapki application me log messages ko manage karne aur customize karne me madad karta hai.

3. Serilog: Serilog ek fast, extensible, aur structured logging library hai, jo .NET applications ke liye available hai. Iska use log messages ko structured format me record karne ke liye kiya ja sakta hai.

Aap in libraries ko apne .NET MVC application me configure karke, application ke various parts me log messages generate kar sakte hain.

Ye log messages aapki application ki debugging aur monitoring me madadgar hote hain, taki aap issues ko identify aur resolve kar sakein.

Log messages ko typically text files, databases, aur external log management systems me store kiya jata hai, taki aap unhe analyze aur visualize kar sakein.

various log levels

Logging me various log levels hote hain, jinhe alag-alag situations aur severity levels ke according use kiya jata hai. Niche diye gaye hain kuch common log levels:

1. Trace: Sabse detailed log level hota hai. Yeh level typically development aur debugging ke samay use hota hai. Isme har choti baat ki bhi information hoti hai.

2. Debug: Debug level bhi development aur debugging ke liye use hota hai. Isme application ke internal state aur actions ki details hoti hain, par production environment me normally disable rehta hai.

3. Info: Info level par log messages aam taur par application ke normal operation aur milestones ko indicate karte hain. Yeh useful information provide karta hai.

4. Warning: Warning level par log messages application ke choti problems ya unexpected situations ko indicate karte hain, lekin application ke functioning me interruption nahi hoti.

5. Error: Error level par log messages serious issues ya errors ko indicate karte hain, jo application ke sahi functioning ko effect karte hain, lekin application ko crash nahi karate.

6. Fatal: Fatal level par log messages sabse serious errors ko indicate karte hain, jo application ko crash ya unusable bana sakte hain.

7. Off: Off level logging me koi bhi log message generate nahi hoti, yani logging bilkul band ho jati hai.

Log levels ka use application ke monitoring aur debugging me hota hai, taki developers aur administrators ko pata chale ki application me kis tarah ki activities aur problems ho rahi hain. Log levels ka sahi tarah se configuration aur management important hota hai, taki aap application ke behavior ko monitor kar sakte hain aur problems ko trace karke resolve kar sakte hain.

Rolling Policies:

.NET me log rolling policies ek important concept hain, jo log files ke management aur maintenance ke liye use hote hain. 

In policies se log files ko automatically rotate aur purane log files ko maintain kiya jata hai. Yani, naye log entries ek naye file me likhi jati hain jab ek nishchit size ya samay ki limit tak pahunch jati hain. Isse log files ki size control me rahti hai aur purane log data ko bina manual intervention ke delete kiya jata hai.

Kuch common log rolling policies .NET me hote hain:

1. Size-based Rolling: Is policy me log file ki size ek limit tak badhti hai, aur jab size limit exceed hoti hai, to ek naya log file create ho jata hai. Purane log file ko rename karke ya archive karke rakh sakte hain.

2. Time-based Rolling: Time-based rolling policy me ek naya log file har naye din, ghante, minute, ya dusre nishchit samay interval ke baad create hota hai. Isse log files ko chronologically organize kiya ja sakta hai.

3. Count-based Rolling: Isme ek nishchit number of log files create kiye jate hain, aur jab maximum count tak pahunch jata hai, to oldest log file overwrite hoti hai ya delete ho jati hai.

4. Custom Rolling: Developers apne custom logic ke sath log rolling policies bhi implement kar sakte hain, jaise ki kisi specific condition ya event ke basis par.

5. Composite Rolling: Composite rolling policy me kuch factors jaise ki size aur time ka combination use kiya jata hai log files ko rotate karne ke liye.


Log rolling policies ki madad se log files ko manageable aur maintainable bana sakte hain, taki unka size control me rahe, aur purane log data ko asani se access kiya ja sake. Aap .NET me various logging libraries jaise ki NLog, log4net, Serilog, etc. ka use karke in policies ko configure aur customize kar sakte hain apne application ke requirements ke hisab se.
What is Logger? Types of Logger? Rolling Poicies of Logger. Various log levels in .net What is Logger? Types of Logger? Rolling Poicies of Logger. Various log levels in .net Reviewed by Rikesh on November 05, 2023 Rating: 5

No comments:

Powered by Blogger.