Web项目中使用的RollingFlatFileTraceListener导致NotSupportedException

时间:2015-09-07 12:29:22

标签: c# .net logging enterprise-library

我们在Web项目中使用RollingFlatFileTraceListener:

如果侦听器尝试转到新文件,则会收到NotSupportedException。

命名= “SeguridadFileListener”

     fileName="C:\Logs\Portal2015\Seguridad.log"
     footer="----------------------"
     formatter="TimeStampAndMessage Formatter"
     header=""
     rollFileExistsBehavior="Overwrite"
     rollInterval="None"
     rollSizeKB="2048"
     timeStampPattern="yyyy-MM-dd HH:mm"
     traceOutputOptions="None"
     filter="All"

我们猜测,fileName属性中缺少的路径信息会导致某种方式无效(web url表示法?),详细信息如下:

异常信息详细信息:

Exception Type: System.NotSupportedException
Message: The given path's format is not supported.
Data: System.Collections.ListDictionaryInternal
TargetSite: System.String CanonicalizePath(System.String, Boolean)
HelpLink: NULL
Source: mscorlib

StackTrace信息详细信息:

at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)

然后,我也得到了这个错误:

Exception Type: System.NullReferenceException
Message: Referencia a objeto no establecida como instancia de un objeto.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void PerformRoll(System.DateTime)
HelpLink: NULL
Source: Microsoft.Practices.EnterpriseLibrary.Logging
HResult: -2147467261

StackTrace信息详细信息:

   en Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener.StreamWriterRollingHelper.PerformRoll(DateTime rollDateTime)
   en Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener.StreamWriterRollingHelper.RollIfNecessary()
   en Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
   en Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerWrapper.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
   en Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache)
   en Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl.ProcessLog(LogEntry log, TraceEventCache traceEventCache)

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

问题是 timeStampPattern属性

timeStampPattern="yyyy-MM-dd HH:mm"

等字符对文件路径无效。

timeStampPattern值有效可以是:

timeStampPattern="yyyyMMdd_HHmm"