我们在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
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
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)
有什么建议吗?
答案 0 :(得分:1)
问题是 timeStampPattern属性值
timeStampPattern="yyyy-MM-dd HH:mm"
:等字符对文件路径无效。
timeStampPattern值有效可以是:
timeStampPattern="yyyyMMdd_HHmm"