语义日志记录不会在Out-Of-Process中记录更新的事件源消息

时间:2014-10-30 14:57:05

标签: c# logging enterprise-library

我在我的应用程序中使用Semantic Logging Out-Of-Process。我创建了一个eventsource类,如下所示

[EventSource(Name = "SemanticLoggingOutOfProcessEventSource")]
public class SampleEventSource : EventSource
{

    public class Keywords
    {
        public const EventKeywords Page = (EventKeywords)1;
        public const EventKeywords DataBase = (EventKeywords)2;
        public const EventKeywords Diagnostic = (EventKeywords)4;
        public const EventKeywords Perf = (EventKeywords)8;
    }

    public class Opcodes
    {
        public const EventOpcode Start = (EventOpcode)20;
        public const EventOpcode Finish = (EventOpcode)21;
        public const EventOpcode Error = (EventOpcode)22;
        public const EventOpcode Starting = (EventOpcode)23;

        public const EventOpcode QueryStart = (EventOpcode)24;
        public const EventOpcode QueryFinish = (EventOpcode)25;
        public const EventOpcode QueryNoResults = (EventOpcode)26;

        public const EventOpcode CacheQuery = (EventOpcode)27;
        public const EventOpcode CacheUpdate = (EventOpcode)28;
        public const EventOpcode CacheHit = (EventOpcode)29;
        public const EventOpcode CacheMiss = (EventOpcode)30;
    }

    public class Tasks
    {
        public const EventTask Page = (EventTask)1;
        public const EventTask DBQuery = (EventTask)2;
        public const EventTask Application = (EventTask)3;            
    }

    [Event(1, Message = "Method1 Starting.", Opcode = Opcodes.Starting, Task = Tasks.DBQuery, Level = EventLevel.Informational, Keywords = Keywords.Perf)]
    public void Method1Starting() { if (this.IsEnabled()) this.WriteEvent(1); }

    [Event(2, Message = "Method1 Ending.", Opcode = Opcodes.Finish, Task = Tasks.DBQuery, Level = EventLevel.Informational, Keywords = Keywords.Perf)]
    public void Method1Ending() { if (this.IsEnabled()) this.WriteEvent(2); }

    [Event(3, Message = "Method2 Starting.", Opcode = Opcodes.Starting, Task = Tasks.DBQuery, Level = EventLevel.Informational, Keywords = Keywords.Perf)]
    public void Method2Starting() { if (this.IsEnabled()) this.WriteEvent(3); }

    [Event(4, Message = "Method2 Ending.", Opcode = Opcodes.Finish, Task = Tasks.DBQuery, Level = EventLevel.Informational, Keywords = Keywords.Perf)]
    public void Method2Ending() { if (this.IsEnabled()) this.WriteEvent(4); }

    public static readonly SampleEventSource outOfProcessLog = new SampleEventSource();                
}

我在packages \ EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1 \ tools \ SemanticLogging-svc.xml中设置了eventsource名称。我启动了语义服务并运行了应用程序。该日志被写入" packages \ EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1 \ tools \ SemanticLogging-svc.runtime.log"文件。我有以下问题:

  1. 每当我更改Message属性时(假设我更改" Method1 Starting。" to" Method1 Started。")。日志再次写为" Method1 Starting。"而不是"方法1开始。"。为什么?我可以实现这一目标的唯一方法是每次有Message属性更新时停止服务并更改EventSource名称,这非常痛苦。有没有其他方法可以在不更改EventSource名称的情况下实现此目的?
  2. 是否可以将消息记录到任何其他日志文件而不是记录到SemanticLogging-svc.runtime.log?
  3. 我只能从20开始创建EventOpcode。我不能从类似于任务的1启动EventOpcodes吗?

0 个答案:

没有答案