Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points of routing rules and context information in NLog

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what are the routing rules and context information in NLog. It is very detailed and has a certain reference value. Friends who are interested must read it!

NLog configure routing rules and context information

Rules: rule nod

Logger: a routing rule

Specific parameters:

Routing rules are mainly used to match logs with output targets, and generally have the following attributes

Name-name of the log source / logger (wildcard * allowed)

Minlevel-the lowest level that matches the range of logs

Maxlevel-the highest level that matches the log range

Level-single log level that matches

Levels-A series of log levels that match, separated by commas.

WriteTo-A series of name attributes of the target node that the log should be written to when the rules match, separated by commas.

Final-Mark the current rule as the last rule. Subsequent rules will not be run even if they match immediately.

Such as:

-all log information of the class Class1 under the namespace Name.Space that is equal to or higher than Debug is written to the target "F1".

-all log information of the class Class1 under the namespace Name.Space that is equal to Debug or Error is written to the target "F1".

-Log information at all levels of all classes under the namespace Name.Space is written to the "f3" and "f4" targets.

-Log information of all classes under the namespace Name.Space and whose level is between Debug and Error (including Debug,Info,Warn,Error) will not be recorded (because this rule does not define writeTo), and other subsequent rules will be ignored (because final= "true" is set here).

NLog supports the following record levels:

The most common recording information of Trace-, which is generally used for general output

Debug- also records information, but it appears less frequently than Trace, and is generally used to debug programs.

Messages of Info- information type

Warn- warning messages, generally used in more important situations

Error- error message

Fatal- fatal exception message. Generally speaking, the program cannot continue execution after a fatal exception occurs.

Priority: Trace > Debug > Info > Warn > Error > Fatal

Layout context information expression

${date} date 2016-08-11 09MU 34MU 33.793

${time} 24 hours HH:mm:ss.mmm.

${longdate} long time 2016-08-05 14 purl 06purl 18.9293

${shortdate} date 2016-08-05

${basedir} root directory

${message} Information

${level} level

${stacktrace} stack information

${callsite} Log Source

These are all the contents of the article "what are the knowledge points of routing rules and context information in NLog". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report