如何在Sentinel日志查看器中使用callsite布局渲染器?

时间:2015-09-21 10:15:06

标签: c# nlog sentinel


我在我的应用程序中使用NLog,我能够将信息记录在不同的目标中,如文件,控制台,EventLog以及NLogViewer。
我正在使用布局作为

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<targets>
  <target name="event" xsi:type="EventLog" layout="${longdate}|${level}|${message}|${event-properties:EventID}" source="NLogDemo" />
  <target name="file" xsi:type="File" fileName="C:\Users\sharathk\Desktop\ToCompare\${shortdate}LoggingDemo.txt" 
          layout="---------NLog File--------${newline}${longdate}=>${level}=>${message}=>${event-properties:EventID}=>${callsite:fileName=true:methodName=true}" />
  <target name="console"  xsi:type="Console" layout="${longdate}|${level}|${message}|${callsite:fileName=true}" />
  <target name="viewer" xsi:type="NLogViewer" layout="${longdate}|${level}|${message}|${callsite:fileName=true}" address="udp://10.100.18.166:9999"/>
</targets>
<rules>
  <logger name="*" minlevel="Trace" writeTo="file,console,viewer" />
</rules>

callSite属性在File,Console和EventLog中显示正确的信息,但 在Sentinel中使用callSite显示任何信息
请任何人帮忙解决这个问题。

1 个答案:

答案 0 :(得分:0)

在您的网络目标中包含类似内容:

df = pd.DataFrame(data1)

dic = {}

for name, jobs in df.groupby('Name').groups.iteritems():
    if not dic:
        dic['Name'] = []
    dic['Name'].append(name)
    for j, job in enumerate(jobs, 1):
        jobstr = 'Job {0}'.format(j)
        jobeffdatestr = 'Job Eff Date {0}'.format(j)
        if jobstr not in dic:
            dic[jobstr] = ['']*(len(dic['Name'])-1)
            dic[jobeffdatestr] = ['']*(len(dic['Name'])-1)
        dic[jobstr].append(df['Job'].ix[job])
        dic[jobeffdatestr].append(df['Job Eff Date'].ix[job])

df2 = pd.DataFrame(dic).set_index('Name')

##         Job 1    Job 2     Job 3 Job Eff Date 1 Job Eff Date 2 Job Eff Date 3
## Name                                                                         
## Jane  Analyst  Manager                 1/1/2015       1/1/2016               
## Joe   Analyst  Manager  Director       1/1/2015       1/1/2016       7/1/2016