I在一个项目中使用NLog(4.7.2),其中NLog日志文件中出现以下异常:
2020-07-03 15:41:52.5324 Debug Watching path 'C:\DEVSTUFF\MyApp\Produkter\MyAppUtveckling\Solution\MyApp.Client.Main\bin\Debug' filter 'NLog.config' for changes.
2020-07-03 15:41:52.5324 Debug --- NLog configuration dump ---
2020-07-03 15:41:52.5324 Debug Targets:
2020-07-03 15:41:52.5513 Debug LogToService Target[LogToService]
2020-07-03 15:41:52.5513 Debug LogMessageEvent Target[communicationLogWindow]
2020-07-03 15:41:52.5633 Debug Rules:
2020-07-03 15:41:52.5633 Debug --- End of NLog configuration dump ---
2020-07-03 15:41:52.5853 Trace FindReachableObject<System.Object>:
2020-07-03 15:41:52.5942 Trace Scanning LogToServiceTarget 'LogToService Target[LogToService]'
2020-07-03 15:41:52.5942 Trace Scanning Property Layout ''${longdate}|${level:uppercase=true}|${logger}|${message}'' NLog.Layouts
2020-07-03 15:41:52.5942 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:52.6132 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.6132 Trace Scanning LongDateLayoutRenderer 'Layout Renderer: ${longdate}'
2020-07-03 15:41:52.6271 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.6271 Trace Scanning UppercaseLayoutRendererWrapper 'Layout Renderer: ${uppercase}'
2020-07-03 15:41:52.6271 Trace Scanning Property Inner 'SimpleLayout=Layout Renderer: ${level}' NLog.Layouts
2020-07-03 15:41:52.6561 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:52.6561 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.6561 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:52.6730 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.6730 Trace Scanning LoggerNameLayoutRenderer 'Layout Renderer: ${logger}'
2020-07-03 15:41:52.6910 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.6910 Trace Scanning MessageLayoutRenderer 'Layout Renderer: ${message}'
2020-07-03 15:41:52.7039 Trace Scanning LogMessageEventTarget 'LogMessageEvent Target[communicationLogWindow]'
2020-07-03 15:41:52.7039 Trace Scanning Property Layout ''${longdate}|${level:uppercase=true}|${logger}|${message}'' NLog.Layouts
2020-07-03 15:41:52.7039 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:52.7219 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.7219 Trace Scanning LongDateLayoutRenderer 'Layout Renderer: ${longdate}'
2020-07-03 15:41:52.7219 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.7388 Trace Scanning UppercaseLayoutRendererWrapper 'Layout Renderer: ${uppercase}'
2020-07-03 15:41:52.7388 Trace Scanning Property Inner 'SimpleLayout=Layout Renderer: ${level}' NLog.Layouts
2020-07-03 15:41:52.7498 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:52.7498 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.7668 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:52.7668 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.7817 Trace Scanning LoggerNameLayoutRenderer 'Layout Renderer: ${logger}'
2020-07-03 15:41:52.7817 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.7817 Trace Scanning MessageLayoutRenderer 'Layout Renderer: ${message}'
2020-07-03 15:41:52.8017 Info Found 22 configuration items
2020-07-03 15:41:52.8127 Debug Unused target checking is started... Rule Count: 0, Target Count: 2
2020-07-03 15:41:52.8127 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: LogToService
2020-07-03 15:41:52.8296 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: communicationLogWindow
2020-07-03 15:41:52.8296 Debug Unused target checking is completed. Total Rule Count: 0, Total Target Count: 2, Unused Target Count: 2
2020-07-03 15:41:52.8296 Trace Initializing Layout Renderer: ${message}
2020-07-03 15:41:52.8476 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:52.8476 Trace Initializing Layout Renderer: ${logger}
2020-07-03 15:41:52.8595 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:52.8595 Trace Initializing Layout Renderer: ${level}
2020-07-03 15:41:52.8595 Trace Initializing SimpleLayout=Layout Renderer: ${level}
2020-07-03 15:41:52.8805 Trace FindReachableObject<System.Object>:
2020-07-03 15:41:52.8805 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:52.8924 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.8924 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:52.9074 Trace Initializing Layout Renderer: ${uppercase}
2020-07-03 15:41:52.9074 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:52.9074 Trace Initializing Layout Renderer: ${longdate}
2020-07-03 15:41:52.9253 Trace Initializing '${longdate}|${level:uppercase=true}|${logger}|${message}'
2020-07-03 15:41:52.9253 Trace FindReachableObject<System.Object>:
2020-07-03 15:41:52.9373 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:52.9373 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.9373 Trace Scanning LongDateLayoutRenderer 'Layout Renderer: ${longdate}'
2020-07-03 15:41:52.9523 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.9523 Trace Scanning UppercaseLayoutRendererWrapper 'Layout Renderer: ${uppercase}'
2020-07-03 15:41:52.9523 Trace Scanning Property Inner 'SimpleLayout=Layout Renderer: ${level}' NLog.Layouts
2020-07-03 15:41:52.9697 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:52.9697 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:52.9697 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:52.9872 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.9872 Trace Scanning LoggerNameLayoutRenderer 'Layout Renderer: ${logger}'
2020-07-03 15:41:52.9987 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:52.9987 Trace Scanning MessageLayoutRenderer 'Layout Renderer: ${message}'
2020-07-03 15:41:52.9987 Trace Initializing LogMessageEvent Target[communicationLogWindow]
2020-07-03 15:41:53.0176 Trace FindReachableObject<NLog.Layouts.Layout>:
2020-07-03 15:41:53.0176 Trace Scanning LogMessageEventTarget 'LogMessageEvent Target[communicationLogWindow]'
2020-07-03 15:41:53.0316 Trace Scanning Property Layout ''${longdate}|${level:uppercase=true}|${logger}|${message}'' NLog.Layouts
2020-07-03 15:41:53.0316 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:53.0475 Trace LogMessageEvent Target[communicationLogWindow] has 1 layouts
2020-07-03 15:41:53.0475 Trace Initializing Layout Renderer: ${message}
2020-07-03 15:41:53.0655 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:53.0655 Trace Initializing Layout Renderer: ${logger}
2020-07-03 15:41:53.0815 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:53.0815 Trace Initializing Layout Renderer: ${level}
2020-07-03 15:41:53.0934 Trace Initializing SimpleLayout=Layout Renderer: ${level}
2020-07-03 15:41:53.0934 Trace FindReachableObject<System.Object>:
2020-07-03 15:41:53.1094 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:53.1094 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:53.1263 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:53.1263 Trace Initializing Layout Renderer: ${uppercase}
2020-07-03 15:41:53.1403 Trace Initializing Layout Renderer: ${literal}
2020-07-03 15:41:53.1403 Trace Initializing Layout Renderer: ${longdate}
2020-07-03 15:41:53.1403 Trace Initializing '${longdate}|${level:uppercase=true}|${logger}|${message}'
2020-07-03 15:41:53.1583 Trace FindReachableObject<System.Object>:
2020-07-03 15:41:53.1583 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:53.1583 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:53.1762 Trace Scanning LongDateLayoutRenderer 'Layout Renderer: ${longdate}'
2020-07-03 15:41:53.1762 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:53.1872 Trace Scanning UppercaseLayoutRendererWrapper 'Layout Renderer: ${uppercase}'
2020-07-03 15:41:53.1872 Trace Scanning Property Inner 'SimpleLayout=Layout Renderer: ${level}' NLog.Layouts
2020-07-03 15:41:53.1872 Trace Scanning SimpleLayout 'SimpleLayout=Layout Renderer: ${level}'
2020-07-03 15:41:53.2073 Trace Scanning Property Renderers 'System.Collections.ObjectModel.ReadOnlyCollection`1[NLog.LayoutRenderers.LayoutRenderer]' System.Collections.ObjectModel
2020-07-03 15:41:53.2073 Trace Scanning LevelLayoutRenderer 'Layout Renderer: ${level}'
2020-07-03 15:41:53.2183 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:53.2183 Trace Scanning LoggerNameLayoutRenderer 'Layout Renderer: ${logger}'
2020-07-03 15:41:53.2183 Trace Scanning LiteralLayoutRenderer 'Layout Renderer: ${literal}'
2020-07-03 15:41:53.2362 Trace Scanning MessageLayoutRenderer 'Layout Renderer: ${message}'
2020-07-03 15:41:53.2362 Trace Initializing LogToService Target[LogToService]
2020-07-03 15:41:53.2362 Trace FindReachableObject<NLog.Layouts.Layout>:
2020-07-03 15:41:53.2538 Trace Scanning LogToServiceTarget 'LogToService Target[LogToService]'
2020-07-03 15:41:53.2538 Trace Scanning Property Layout ''${longdate}|${level:uppercase=true}|${logger}|${message}'' NLog.Layouts
2020-07-03 15:41:53.2658 Trace Scanning SimpleLayout ''${longdate}|${level:uppercase=true}|${logger}|${message}''
2020-07-03 15:41:53.2658 Trace LogToService Target[LogToService] has 1 layouts
2020-07-03 15:41:53.2658 Info Configuration initialized.
2020-07-03 15:41:53.2847 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.0.11381. Product version: 4.7.0+4d138800820311d0b60b6437f1dd2ed1d571d47d.
2020-07-03 15:41:53.2847 Debug Targets not configured for logger: MyAppKontext.Kontext
2020-07-03 15:42:51.3143 Debug Targets not configured for logger: GeneralLogger
2020-07-03 15:42:51.3143 Debug Targets not configured for logger: CommunicationLogger
2020-07-03 15:42:51.3143 Debug Targets not configured for logger: FileLogger
触发日志函数的C#代码如下所示:
public void Log(LogData logData)
{
SerlizeParameters(logData);
var logEvent = new LogEventInfo();
logEvent.Level = logData.LogLevel.ToLogLevel();
logEvent.Message = JsonConvert.SerializeObject(logData, Formatting.Indented);
logEvent.Properties.Add("logdata", logData);
logEvent.Parameters = new object[1] { logData };
_genLogger.Log(logEvent);
}
nlog.config如下所示:
<targets>
<target name="LogToService" xsi:type="LogToService"/>
<target name="communicationLogWindow" xsi:type="LogMessageEvent"/>
<target xsi:type="File"
name="communicationFileLog"
fileName="${basedir}/logs/${shortdate}.log"
maxArchiveDays="5"
maxArchiveFiles="10">
<!--SkipCharsInParameterObject = Starting position within the serialized string -->
<!--TakeCharsInParameterObject = Lengh of data(char) to serialize -->
<!--TakeCharsInParameterObject = 0 - No serialization -->
<!--TakeCharsInParameterObject = -1 - Serialize everything -->
<!--FilterServiceMethodName = Exact name of servicemethods to listen on, comma(,) can be used to filter on more then 1 method. -->
<!--FilterCallDirection = Send, Receive, ReceiveMQ, Unknown(all) -->
<layout xsi:type="JsonNetLayout"
SkipCharsInParameterObject="0"
TakeCharsInParameterObject="1000"
FilterServiceMethodName=""
FilterCallDirection="Unknown"/>
</target>
</targets>
<rules>
<logger name="GeneralLogger" minlevel="Warn" writeto="LogToService"></logger>
<logger name="CommunicationLogger" minlevel="Trace" writeto="communicationLogWindow"></logger>
</rules>
我的自定义目标从来没有被触发过,很可能异常在之前就被抛出了。
我尝试将logEvent.message设置为“test”,但这什么也不做。 为什么我会得到这个异常?
问候
编辑:当我关闭结构日志登录(parseMessageTemplates=“false”)时,我在日志文件中得到的是这个,而不是异常:
2020-07-03 16:46:04.4968 Debug Targets not configured for logger: MyAppKontext.Kontext
2020-07-03 16:46:16.7226 Debug Targets not configured for logger: GeneralLogger
2020-07-03 16:46:16.7226 Debug Targets not configured for logger: CommunicationLogger
2020-07-03 16:46:16.7356 Debug Targets not configured for logger: FileLogger
您不能在消息中发送JSON。 消息被分析为消息模板(带有{0}
或{Named}
令牌。) 参数
用于创建消息,将其视为一个花哨的字符串。格式
。
您可以在属性中传递数据,就像在您的示例中一样,但不要在消息或参数中发送数据。
所以这是可以的:
var logEvent = new LogEventInfo();
logEvent.Level = logData.LogLevel.ToLogLevel();
logEvent.Message = "normal message"
logEvent.Properties.Add("logdata", logData);
_genLogger.Log(logEvent);
我正在从2X迁移到5X,我的查询失败了。这是我得到的错误: [multi_match]格式错误的查询,预期[END_OBJECT]但找到[FIELD_NAME]“,”line“:32,”col“:13}”,“type”:“parsing_exception”,“reason”:“[multi_match]格式错误的查询,预期[END_OBJECT]但找到[FIELD_NAME]”,“line”:3
我对elasticsearch查询有一些问题。当我使用查询代码时,它反馈消息[bool]格式错误的查询,预期的是[END_OBJECT],但发现的是[FIELD_NAME]。
我正在为我的spring项目构建一个本机查询。有人知道这是什么问题吗? org.hibernate.hql.internal.ast.QuerySyntaxException:需要IDENT,在第1行第348列附近找到“:”[选择e.first_name作为第一名,e.last_na me作为最后一名,jh.start_date作为开始日期,jh.end_date作为结束日期,j.job_titl
和请求模式模型 当我运行代码并从服务中请求时,我得到
我想从改造中接收数据,并在 中设置它,但我有一个例外 改造。错误:com.google.gson。JsonSyntaxException:java.lang.IllegalStateException:应为BEGIN_$ 我必须做什么? 数据如下:
问题内容: 我使用XlsxWriter处理python,但一直在尝试解决此问题,但没有成功: 我的应用程序必须创建一个Xlsx文件,其中的数据以表格形式显示。该表有一些空单元格。 我想为某些单元格设置边框以为表格制作网格,所以我使用: 为了将边框应用于这些单元。然后,我在表上写数据。 由于表的布局非常复杂,因此写入数据将很容易,一旦编写完所有内容,就将格式应用于具有边框的单元格,但我找不到方法。
在ipython中 但是在python中: 为什么会发生这个奇怪的错误?请帮我弄清楚。