【发布时间】:2012-01-23 19:33:31
【问题描述】:
51Degrees.mobi.config 中的以下行为我的 ASP.NET MVC 4 项目的每个控制器操作增加了 2-3 秒的加载时间:
<fiftyOne>
<log logFile="~/bin/App_Data/51Log.txt" logLevel="Info" />
...
</fiftyOne
同样的事情发生在 ASP.NET MVC 3 上。如果我删除 <log> 部分,页面几乎会立即加载。我正在使用二进制设备数据库进行检测,如下所示:
<detection binaryFilePath="~/App_Data/51Degrees.mobi-Lite-2012.01.05.dat" />
将logLevel 设置为Debug 会导致以下异常:
`Storage scopes cannot be created when _AppStart is executing.`
为什么这会导致如此急剧的减速?这是更深层次问题的征兆吗?
会不会与依赖注入的 StructureMap 不兼容?
更新:感谢@James Rosewell,我弄清楚了为什么日志记录会减慢我的应用程序。它与 logFile 路径 有关。每次 51Degrees 写入 ~/bin 目录中的 51Log.txt 文件时,都会导致 IIS 回收池并重新加载所有模块。将日志路径更改为~/App_Data 即可解决问题。
【问题讨论】:
标签: asp.net-mvc performance structuremap asp.net-mvc-4 51degrees