Programmatic configuration of NLog internal logger

后端 未结 1 919
广开言路
广开言路 2021-01-21 18:22

Can anyone please help with programmatic configuration of NLog internal logger?

I have various targets and the email target is not sending any email, although it does h

1条回答
  •  孤城傲影
    2021-01-21 18:46

    Soms examples:

    // 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;
    

    See the NLog wiki

    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+)

    0 讨论(0)
提交回复
热议问题