• Kentico lots of log with event code “CREATEOBJ” and “UPDATEOBJ”


    问题

    You are right, our customer have written a class inherit CustomTableItem class, which named as EventLogItem. We also have a CustomTable named as EventLog.

    The problem should be, why we have so many logs with event code “CREATEOBJ” and “UPDATEOBJ”? I believe this kind of log was written by Kentico automatically.

    Currently the log with event code “CREATEOBJ” and “UPDATEOBJ” are distracting when we try to do the troubleshooting.

    Do you have the feature to turn off such kind of log?  I would like to ignore such kind of log.

    回答

    These events are logged when you create or update the object.

    This was requested by many customers so they can trace who changed what and when.

    IF you do not want to log these, customize the event logging as described in the documentation:

    https://docs.xperience.io/k12sp/custom-development/handling-global-events/customizing-event-logging 

    using CMS;
    
    using CMS.DataEngine;
    using CMS.EventLog;
    using CMS.Base;
    
    // Registers the custom module into the system
    [assembly: RegisterModule(typeof(CustomInitializationModule))]
    
    public class CustomInitializationModule : Module
    {
        // Module class constructor, the system registers the module under the name "CustomInit"
        public CustomInitializationModule()
            : base("CustomInit")
        {
        }
    
        // Contains initialization code that is executed when the application starts
        protected override void OnInit()
        {
            base.OnInit();
    
            // Assigns a handler to the LogEvent.Before event
            EventLogEvents.LogEvent.Before += LogEvent_Before;
        }
    
        private void LogEvent_Before(object sender, LogEventArgs e)
        {
            // Gets an object representing the event that is being logged
            EventLogInfo eventLogRecord = e.Event;
    
            // Cancels logging for events with the "CREATEOBJ" or "UPDATEOBJ" event codes.
            // Disables event log records notifying about the creation or update of objects in the system,
            // but still allows events related to object deletion.
            string eventCode = eventLogRecord.EventCode;
            if (eventCode.EqualsCSafe("CREATEOBJ") || eventCode.EqualsCSafe("UPDATEOBJ"))
            {
                e.Cancel();
            }
    
            // Adds a custom message to the Description field for events of the Information type
            if (eventLogRecord.EventType.EqualsCSafe("I"))
            {
                eventLogRecord.EventDescription += " Custom message";
            }
        }
    }

    查看日志的时候,可以把这种数据过滤掉,does not contain

  • 相关阅读:
    Saltstack module acl 详解
    Saltstack python client
    Saltstack简单使用
    P5488 差分与前缀和 NTT Lucas定理 多项式
    CF613D Kingdom and its Cities 虚树 树形dp 贪心
    7.1 NOI模拟赛 凸包套凸包 floyd 计算几何
    luogu P5633 最小度限制生成树 wqs二分
    7.1 NOI模拟赛 dp floyd
    springboot和springcloud
    springboot集成mybatis
  • 原文地址:https://www.cnblogs.com/chucklu/p/16426618.html
Copyright © 2020-2023  润新知