Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
有什么情况可能导致不记事件日志? – 扎老铁
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
class="post-53201 post type-post status-publish format-standard hentry">

有什么情况可能导致不记事件日志?

1.你反编译看下 bitlab.logging.dll 的 EventLogService 的 Handle 方法内是否直接 return 了
2.如果 Event 对象序列号为 JSON 失败了,也会记 EventLog,但是 EventSource 字段为空
3.如果 Event 对象的 Message 获取产生了异常,那么这个日志不会记录

4.有一个版本的Bitlab.Logging.dll不对,很多项目都引了不对的版本,替换掉就好了

public void Handle(IEvent @event)
       {
           //Event e;
           //e.Ip = null;
           //  return;
           //Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.ArteryFilter
           //return;
           //if (@event.IsBegin())
           //{
           //    return;
           //}
           if (@event is IStateEvent)
           {
               var stateEvent = (IStateEvent)@event;
               if (stateEvent.Event is HttpApplicationEvent)
               {
                   return;
               }
           }
           //if (@event is Begin<HttpApplicationEvent> || @event is Success<HttpApplicationEvent> || @event is End<HttpApplicationEvent>)
           //{
           //    return;
           //}
           //if (@event is HttpApplicationEvent)
           //{
           //    return;
           //}

// 如果 Event 对象序列号为 JSON 失败了,也会记 EventLog,但是 EventSource 字段为空
           string eventSource = SerializeEventSource(@event);
           var eventType = @event.GetType();
           var log = new EventLog
           {
               Indent = @event.Indent,
               Date = @event.Date,
               ThreadId = @event.ThreadId,
               EventType = eventType,
// 如果 Event 对象的 Message 获取产生了异常,那么这个日志不会记录
               Message = @event.Message,
               EventSource = eventSource,
               UserId = @event.Principal.UserId(),
               Username = @event.Principal.Username(),
           };
           if (log.Date.IsEmpty())
           {
               log.Date = DateTime.Now;
           }
           //var user = (User)@event.Principal;
           //if (user != null)
           //{
           //    log.UserId = user.UserId;
           //    log.Username = user.Username;
           //}
           System.Threading.ThreadPool.QueueUserWorkItem((state) =>
           //System.Threading.Tasks.Task.Factory.StartNew(() =>
           {
               using (repository.BeginSessionLifecycle())
               {
                   repository.SaveLog(log);
               }
           });
       }

 

发表评论

电子邮件地址不会被公开。