Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在aspnet5 rc1/mvc6中使用企业库 如何在Aspnet5 web应用程序项目中使用企业库?应该使用哪个nuget包 在早期的asp.net网站中,web.config用于指定configSections、dataConfiguration、defaultDatabase和cachingConfiguration。在Aspnet5中如何/在何处指定这些值_C#_Configuration_Asp.net Core_Enterprise Library_Asp.net Core Mvc - Fatal编程技术网

C# 如何在aspnet5 rc1/mvc6中使用企业库 如何在Aspnet5 web应用程序项目中使用企业库?应该使用哪个nuget包 在早期的asp.net网站中,web.config用于指定configSections、dataConfiguration、defaultDatabase和cachingConfiguration。在Aspnet5中如何/在何处指定这些值

C# 如何在aspnet5 rc1/mvc6中使用企业库 如何在Aspnet5 web应用程序项目中使用企业库?应该使用哪个nuget包 在早期的asp.net网站中,web.config用于指定configSections、dataConfiguration、defaultDatabase和cachingConfiguration。在Aspnet5中如何/在何处指定这些值,c#,configuration,asp.net-core,enterprise-library,asp.net-core-mvc,C#,Configuration,Asp.net Core,Enterprise Library,Asp.net Core Mvc,至于配置,..Asp.NET5/MVC6有另一种配置方式,它可以读取任何格式的配置,最著名的是json、ini和Xml 如果您在web.config中有自己的配置,您仍然可以阅读它们并逐一浏览它们 <configuration> <loggingConfiguration name="" tracingEnabled="true" defaultCategory="Trace"> <listeners> <add name

至于配置,..Asp.NET5/MVC6有另一种配置方式,它可以读取任何格式的配置,最著名的是json、ini和Xml

如果您在web.config中有自己的配置,您仍然可以阅读它们并逐一浏览它们

    <configuration>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="Trace">
    <listeners>
      <add name="General Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="General.log" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="Callstack" asynchronous="false" asynchronousBufferSize="3000" />
      <add name="Exception Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Exceptions.log" formatter="Text Formatter" rollInterval="Hour" rollSizeKB="100" traceOutputOptions="Callstack" filter="Error" asynchronous="false" asynchronousBufferSize="3000" />
      <add name="Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Trace.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId" asynchronousBufferSize="3000" />
      <add name="SecurityAudit Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="SecurityAudit.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId" asynchronousBufferSize="3000" />
      <add name="Unprocessed Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Unprocessed.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" rollSizeKB="0" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" asynchronous="false" asynchronousBufferSize="3000" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)} Message: {message} Category: {category}  Win32 ThreadId:{win32ThreadId} Extended Properties: {dictionary({key} - {value}|)}" name="One Liner Formatter" />
    </formatters>
然后,您可以使用这些变量来构建LoggingConfiguration对象并将其传递给logger


这似乎很麻烦,如果您更喜欢使用Xml解析器,那么请继续,但最好的方法是在EL中查找解析器,因为它是开源的,并且它以与您相同的方式读取配置。

至于配置。..Asp.NET5/MVC6有另一种方式进行配置,它可以读取任何格式的配置,最著名的是json、ini和Xml

如果您在web.config中有自己的配置,您仍然可以阅读它们并逐一浏览它们

    <configuration>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="Trace">
    <listeners>
      <add name="General Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="General.log" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="Callstack" asynchronous="false" asynchronousBufferSize="3000" />
      <add name="Exception Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Exceptions.log" formatter="Text Formatter" rollInterval="Hour" rollSizeKB="100" traceOutputOptions="Callstack" filter="Error" asynchronous="false" asynchronousBufferSize="3000" />
      <add name="Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Trace.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId" asynchronousBufferSize="3000" />
      <add name="SecurityAudit Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="SecurityAudit.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId" asynchronousBufferSize="3000" />
      <add name="Unprocessed Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Unprocessed.log" footer="" formatter="One Liner Formatter" header="" rollInterval="Day" rollSizeKB="0" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" asynchronous="false" asynchronousBufferSize="3000" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)} Message: {message} Category: {category}  Win32 ThreadId:{win32ThreadId} Extended Properties: {dictionary({key} - {value}|)}" name="One Liner Formatter" />
    </formatters>
然后,您可以使用这些变量来构建LoggingConfiguration对象并将其传递给logger


这似乎很麻烦,如果您更喜欢使用Xml解析器,那么继续吧,但最好的方法是在EL中查找解析器,因为它是开源的,并且它正在以与您相同的方式读取配置。

我恐怕要告诉您,我们(在Unity上投入了大量资金)将不得不很快放弃,转而使用另一种解决方案。请参考此链接,尽管我已经看到了一些使用unity和MVC6的实现,但我建议您四处看看并扩展思路,以获得更好的解决方案。我不敢告诉你们,我们(在团结方面投入了大量资金)将不得不很快放弃,转向另一个解决方案。请参考此链接,尽管我已经看到了一些使用unity和MVC6的实现,但我建议您四处看看并扩展思路,以获得更好的解决方案。
using (LogWriter defaultWriter = new LogWriter(config))
                {
                    var log = new LogEntry { Message = message };
                    defaultWriter.Write(log);
                }