F# NLog和作为进程运行的控制台应用程序

F# NLog和作为进程运行的控制台应用程序,f#,nlog,F#,Nlog,我在运行控制台应用程序作为隐藏进程时遇到了nlog问题。未写入日志条目 我在nlog.config文件中配置了两个目标(控制台、文件),如果我手动运行控制台应用程序,这些目标可以正常工作 nlog.config: 负责启动console应用程序进程的我的代码: let setupProcess (enviromentName) (parameter) = let targetPath = getTargetPath enviromentName let e

我在运行控制台应用程序作为隐藏进程时遇到了nlog问题。未写入日志条目

我在nlog.config文件中配置了两个目标(控制台、文件),如果我手动运行控制台应用程序,这些目标可以正常工作

nlog.config:


负责启动console应用程序进程的我的代码:

 let setupProcess (enviromentName) (parameter) = 
        let targetPath = getTargetPath enviromentName
        let executable = System.IO.Path.Combine(targetPath, executable)
        let startInfo = new ProcessStartInfo()
        startInfo.WindowStyle <- System.Diagnostics.ProcessWindowStyle.Normal
        startInfo.FileName <- executable
        startInfo.Arguments <- parameter
        startInfo.RedirectStandardOutput <- true
        startInfo.UseShellExecute <- false
        startInfo
let setupProcess(环境名称)(参数)=
让targetPath=getTargetPath环境名称
让executable=System.IO.Path.Combine(targetPath,executable)
让startInfo=newprocessstartinfo()
startInfo.WindowStyle已经修好了

<variable name="logFilename" value="${basedir}/logs/${shortdate}.log"/>


windows服务的默认目录是C:\windows\System32,因此我必须将${basedir}添加到输出日志路径中,因此现在它指向安装windows服务时的位置。

日志条目是否未写入文件、控制台或两者?如果您的程序只执行Console.WriteLine,而不涉及NLog,会发生什么情况?Console.WriteLine可以正常工作,但登录Console或文件则不行。当我将lib作为windows服务运行时,情况也是如此。
<variable name="logFilename" value="${basedir}/logs/${shortdate}.log"/>