NLog 内部记录器的编程配置
Programmatic configuration of NLog internal logger
任何人都可以帮助 NLog 内部记录器的编程配置吗?
我有多个目标,电子邮件目标没有发送任何电子邮件,尽管它有日志记录规则。所以我希望通过启用内部日志来获得更多见解。
但是我进行了编程配置,但没有找到任何在代码中设置内部记录器的资源。
Soms 示例:
// enable internal logging to the console
NLog.Common.InternalLogger.LogToConsole = true;
// enable internal logging to a file
NLog.Common.InternalLogger.LogFile = "c:\log.txt";
// enable internal logging to a custom TextWriter
NLog.Common.InternalLogger.LogWriter = new StringWriter(); //e.g. TextWriter writer = File.CreateText("C:\perl.txt")
// set internal log level
NLog.Common.InternalLogger.LogLevel = LogLevel.Trace;
Internal logging can be configured through code by setting the following properties on InternalLogger class:
- InternalLogger.LogLevel - specifies internal logging level
- InternalLogger.LogFile - specifies name of the log file (null will disable logging to a file)
- InternalLogger.LogToConsole - enables or disables logging to the console
- InternalLogger.LogToConsoleError - enables or disables logging to the console error stream
- InternalLogger.LogToTrace - enables or disables logging to System.Diagnostics.Trace (introduced in NLog 4.3)
- InternalLogger.LogWriter - specifies a TextWriter object to use for logging
- InternalLogger.IncludeTimestamp - enables or disables whether timestamps should be included in the internal log output (NLog 4.3+)
任何人都可以帮助 NLog 内部记录器的编程配置吗?
我有多个目标,电子邮件目标没有发送任何电子邮件,尽管它有日志记录规则。所以我希望通过启用内部日志来获得更多见解。
但是我进行了编程配置,但没有找到任何在代码中设置内部记录器的资源。
Soms 示例:
// enable internal logging to the console
NLog.Common.InternalLogger.LogToConsole = true;
// enable internal logging to a file
NLog.Common.InternalLogger.LogFile = "c:\log.txt";
// enable internal logging to a custom TextWriter
NLog.Common.InternalLogger.LogWriter = new StringWriter(); //e.g. TextWriter writer = File.CreateText("C:\perl.txt")
// set internal log level
NLog.Common.InternalLogger.LogLevel = LogLevel.Trace;
Internal logging can be configured through code by setting the following properties on InternalLogger class:
- InternalLogger.LogLevel - specifies internal logging level
- InternalLogger.LogFile - specifies name of the log file (null will disable logging to a file)
- InternalLogger.LogToConsole - enables or disables logging to the console
- InternalLogger.LogToConsoleError - enables or disables logging to the console error stream
- InternalLogger.LogToTrace - enables or disables logging to System.Diagnostics.Trace (introduced in NLog 4.3)
- InternalLogger.LogWriter - specifies a TextWriter object to use for logging
- InternalLogger.IncludeTimestamp - enables or disables whether timestamps should be included in the internal log output (NLog 4.3+)