在Global.asax.cs内部,get:对象同步方法是从不同步的代码块调用的。
protected void Application_Start()
{
InitContainer();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
ControllerBuilder.Current.SetControllerFactory(typeof(UnityControllerFactory));
CheckForAndMinify();
Logger.Write("test"); //exception
// if (System.Diagnostics.Debugger.IsAttached)
// MvcContrib.Routing.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
//RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}环境:
Mvc2
之前启动
相关的web.config条目:
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>和
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="GeneralRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\rolling2.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="2056" maxArchivedFiles="2" filter="Warning"/>
<add name="EspionageRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\EspRolling.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="1024" maxArchivedFiles="2" traceOutputOptions="DateTime"/>
<add name="SnapshotRolling" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="~\App_Data\SnapRolling.log" formatter="Text Formatter" rollInterval="Day" rollSizeKB="1024" maxArchivedFiles="2" traceOutputOptions="DateTime"/>
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Title:{title}{newline}
Category: {category}{newline}
Message: {message}{newline}
Timestamp: {timestamp}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="GeneralRolling"/>
</listeners>
</add>
<add switchValue="All" name="Espionage">
<listeners>
<add name="EspionageRolling"/>
</listeners>
</add>
<add switchValue="All" name="SnapShot">
<listeners>
<add name="SnapshotRolling"/>
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="GeneralRolling"/>
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category"/>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="GeneralRolling"/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>我试图确保记录器在应用程序启动时工作,这样应用程序就不会启动,看起来正确,然后在第一次尝试记录某件事情发生时就会死掉。
日志xml配置没有改变,它以前是工作的。主要的改变是添加了Unity,并将应用程序从linq切换到sql。我还没有确认此代码是否在部署环境中工作,因此它可能出于某种原因在适当的环境中工作,而不是在本地。
发布于 2011-02-23 03:51:51
如果您在Visual之外运行该应用程序,它会崩溃吗?你所看到的是与团结有关的问题,以及它是如何创造单身者的。如果将vs设置为只显示未处理的用户异常,那么就不会再看到它了。我刚才也有同样的问题。是弱智。我在企业图书馆4中没有看到这个,只是在5中。
https://stackoverflow.com/questions/4035437
复制相似问题