Mono Nlog控制台目标不工作?

Mono Nlog控制台目标不工作?,mono,nlog,Mono,Nlog,我有一个非常简单的控制台应用程序。我添加了带有控制台目标的Nlog,但在mono(在windows和ubuntu上)中运行时,我无法让它工作。我尝试了文件目标,它工作了。 我错过了什么 代码 class Program { private static Logger logger = LogManager.GetCurrentClassLogger(); static void Main(string[] args) { Type t = Type.Get

我有一个非常简单的控制台应用程序。我添加了带有控制台目标的Nlog,但在mono(在windows和ubuntu上)中运行时,我无法让它工作。我尝试了文件目标,它工作了。 我错过了什么

代码

class Program
{
    private static Logger logger = LogManager.GetCurrentClassLogger();
    static void Main(string[] args)
    {
        Type t = Type.GetType("Mono.Runtime");
        if (t != null)
            Console.WriteLine("You are running with the Mono VM");
        else
            Console.WriteLine("You are running something else");

        Console.WriteLine("Lets go Mono");
        logger.Trace("Sample trace message");
        logger.Debug("Sample debug message");
        logger.Info("Sample informational message");
        logger.Warn("Sample warning message");
        logger.Error("Sample error message");
        logger.Fatal("Sample fatal error message");
    }
}
 <package id="NLog" version="4.3.10" targetFramework="net452" />
配置

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <targets async="true">
    <target name="console" xsi:type="Console"/>
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="console" />
  </rules>
</nlog>

Nlog软件包

class Program
{
    private static Logger logger = LogManager.GetCurrentClassLogger();
    static void Main(string[] args)
    {
        Type t = Type.GetType("Mono.Runtime");
        if (t != null)
            Console.WriteLine("You are running with the Mono VM");
        else
            Console.WriteLine("You are running something else");

        Console.WriteLine("Lets go Mono");
        logger.Trace("Sample trace message");
        logger.Debug("Sample debug message");
        logger.Info("Sample informational message");
        logger.Warn("Sample warning message");
        logger.Error("Sample error message");
        logger.Fatal("Sample fatal error message");
    }
}
 <package id="NLog" version="4.3.10" targetFramework="net452" />

您的代码和配置看起来有效

NLog 4.3.10的Mono上的控制台目标存在问题。控制台是否可用的检测无法正常工作,因为
环境。UserInteractive
无法在Mono上工作

现在为Mono设置
detectConsolleAvailable=“false”
,以便:


您的代码和配置看起来有效

NLog 4.3.10的Mono上的控制台目标存在问题。控制台是否可用的检测无法正常工作,因为
环境。UserInteractive
无法在Mono上工作

现在为Mono设置
detectConsolleAvailable=“false”
,以便:



现在可以正常工作了。即将开始我的第一个mono项目-很高兴有nlog可用,谢谢大家。即将开始我的第一个mono项目-很高兴有nlog可用,谢谢