使用控制台查看NLog信息

Mar*_*cus 1 logging nlog

这可能是一个非常愚蠢的问题,但我们走了.我的Web应用程序中有以下NLog.config,但是对话框如何/何时打开并显示信息,或者我是否需要启动它并导航到特定目录或其他内容?

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.netfx35.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target xsi:type="ColoredConsole"
            name="Debug"
            layout="${message} ${exception}">
      <highlight-row backgroundColor="Black"
                     foregroundColor="DarkCyan"
                     condition="true"/>
    </target>
  </targets>
  <rules>
    <logger name="Raven.Client.*" writeTo="Debug"/>
  </rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)

小智 7

实际上,您可以使用以下代码并行实例化非控制台程序的控制台:

static public class LogConsole
{
    static public void Instantiate()
    {
        AllocConsole();
    }

    [DllImport("kernel32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static private extern bool AllocConsole();
}
Run Code Online (Sandbox Code Playgroud)