trace - 如何在 F# 交互中启用跟踪

标签 trace f#-interactive

我想查看我使用的库的输出。

它使用简单的 Trace 打印中间信息,在我的实验中,我使用 F# Interactive。

我尝试过的:

Console.Out.WriteLine("Hello")                                      // prints "Hello" :)
type MyListener() =
    inherit TraceListener()
    override u.Write (msg : string) = printf "Trace: %s" msg
    override u.WriteLine (msg : string) = printfn "Trace: %s" msg
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out))       // prints "val it : int = 1"
Trace.Listeners.Add(new MyListener())                               // prints "val it : int = 2"
Trace.AutoFlush <- true                                             // prints "val it : unit = ()"
Trace.TraceInformation("test")                                      // prints "val it : unit = ()".

最后一行不会产生任何与“测试”相关的内容。 显然,我需要启用调试标志或设置属性。

如何追踪

最佳答案

我在尝试调试我计划在 Azure 中使用的库时发现了这一点,其中跟踪是更有用的日志记录选项之一。 在 VS2013 中,您可以在“工具”->“选项”->“F# 工具”->“F# 交互”中设置传递给 FSI 的标志。这使我能够读取 fsi 窗口中的跟踪输出。

我已将我的设置为: --optimize- --readline+ --debug+ -d:TRACE

screenshot of fsi settings

关于trace - 如何在 F# 交互中启用跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19025275/

相关文章:

logging - 如何在Cassandra服务器上跟踪查询?

java - 使用 Spring 添加记录器

F# 交互式和性能分析器

macos - 在 MAC OSX 和 Ubuntu 上的 F# 中,我在 4.0 中运行 FSI 时出错

r - 跟踪顺序 plotly R

java - 什么是 JAVA 执行()?

linux - 跟踪 pthread 调度

F#将'一个可区分的联合转换为字符串

f# - 减去 Map<'a, int> 的两个 Map

macos - 在 Mac 上以 32 位模式运行交互式 F#