Example #1
0
        public void WriteInfoLog(LogEnt ent)
        {
            lock (obj)
            {
                logQueue.Enqueue(ent);
            }
//            if (logInfo.IsInfoEnabled)
        }
Example #2
0
        private void LogHandle()
        {
            //可能这里不需要做队列处理?log4支持可以设置线程安全?
            LogEnt logEnt = null;

            try
            {
                while (true)
                {
                    while (logQueue.Count > 0)
                    {
                        lock (obj)
                        {
                            logEnt = logQueue.Dequeue();
                        }
                        logInfo.Info(JsonConvert.SerializeObject(logEnt));
                    }
                }
            } catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }