سؤال

i have some f# projects which use NLog for logging. And logging works fine when i use .exe produced by projects, i see output in files or console.

But now i need to use my types (which uses logging) defined in my project in fsx-script, and i got in trouble.

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. What have i missed?

هل كانت مفيدة؟

المحلول

I'm currently have no access to computer to check, but likely your NLogcannot pick up its configuration, when being fired within a fsi script.

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

For F# 3.x on Windows the location is usually 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.

نصائح أخرى

I dont know NLog, but may be you need to redirect the output.

Console.SetOut(someClassDerivingFromStringWriter)
Console.SetError(someClassDerivingFromStringWriter)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top