v9.7.2018.0421   支持运行时修改DAL连接字符串
大石头 authored at 2018-04-21 14:00:47
1.24 KiB
X
using System;
using System.IO;
using NewLife.Log;
using NewLife.Net.Sockets;

namespace NewLife.Net.Application
{
    /// <summary>日志服务</summary>
    public class LogServer : NetServer<LogServer.LogSession>
    {
        /// <summary>实例化一个日志服务</summary>
        public LogServer()
        {
            // 默认514端口
            Port = 514;

            Name = "日志服务";
        }

        /// <summary>日志会话</summary>
        public class LogSession : NetSession
        {
            /// <summary>实例化</summary>
            public LogSession()
            {
                // 不需要日志前缀
                //LogPrefix = "";
            }

            /// <summary>开始会话</summary>
            public override void Start()
            {
                Log = XTrace.Log;

                LogPrefix = "[{0}]".F(ID);

                base.Start();
            }

            /// <summary>已重载。</summary>
            /// <param name="e"></param>
            protected override void OnReceive(ReceivedEventArgs e)
            {
                if (e.Length == 0) return;

                WriteLog("{0}", e.ToStr());
            }
        }
    }
}