[英]How to set up NLog in F# script (fsx)
i have some f# projects which use NLog for logging. 我有一些使用NLog进行日志记录的f#项目。 And logging works fine when i use .exe produced by projects, i see output in files or console.
当我使用由项目生成的.exe时,日志记录工作正常,我在文件或控制台中看到输出。
But now i need to use my types (which uses logging) defined in my project in fsx-script, and i got in trouble. 但是现在我需要使用我的项目在fsx-script中定义的类型(使用日志记录),这给我带来了麻烦。
Part of my script 我脚本的一部分
#r "NLog.dll"
#r "Emulators.dll" // contains some types which uses NLog
#r "DeviceEmulator.exe" // also contains types which uses NLog
// instantiating and run objects
All works fine but i does not see output from NLog neither in console nor in file. 一切正常,但我既不在控制台中也未在文件中看不到NLog的输出。 What have i missed?
我错过了什么?
I'm currently have no access to computer to check, but likely your NLog
cannot pick up its configuration, when being fired within a fsi
script. 我目前无法访问计算机进行检查,但是当在
fsi
脚本中被激发时,您的NLog
可能无法获取其配置。
You may want finding nlog.config
file within your compiled F# projects and copying it to the directory, where your fsi.exe
( FsiAnyCPU.exe
for 64-bit fsi
) is located side by side with Fsi.exe.config
( FsiAnyCPU.exe.config
). 您可能希望找到
nlog.config
您编译F#项目中的文件,并将其复制到该目录,你的fsi.exe
( FsiAnyCPU.exe
64位fsi
)位于并排着Fsi.exe.config
( FsiAnyCPU.exe.config
)。
For F# 3.x on Windows the location is usually C:\\Program Files (x86)\\Microsoft SDKs\\F#\\3.0\\Framework\\v4.0
. 对于Windows上的F#3.x,该位置通常为
C:\\Program Files (x86)\\Microsoft SDKs\\F#\\3.0\\Framework\\v4.0
。
Alternatively, you may switch to configuring NLog
from your code and run the configuration piece from your script. 或者,您可以从代码中切换到配置
NLog
,然后从脚本中运行配置文件。
I dont know NLog, but may be you need to redirect the output. 我不知道NLog,但可能是您需要重定向输出。
Console.SetOut(someClassDerivingFromStringWriter)
Console.SetError(someClassDerivingFromStringWriter)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.