标签:var type collect details ogg etl log4 space summary
SuperSocket 允许你自定义你的 Logger。 例如,你如果想要把你的业务操作日志保存到一个独立的地方,你仅需要在log4net配置文件中添加一个新的 logger 并为这个 logger 设置相应的 appender(假设你默认使用log4net):
<appender name="myBusinessAppender">
<!--Your appender details-->
</appender>
<logger name="MyBusiness" additivity="false">
<level value="ALL" />
<appender-ref ref="myBusinessAppender" />
</logger>
然后在代码中创建这个logger实例:
var myLogger = server.LogFactory.GetLog("MyBusiness");
使用除 log4net 之外的日志框架
SuperSocket 支持你通过接口实现自己的log factory:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SuperSocket.SocketBase.Logging
{
/// <summary>
/// LogFactory Interface
/// </summary>
public interface ILogFactory
{
/// <summary>
/// Gets the log by name.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
ILog GetLog(string name);
}
}
接口 ILogFactory 和 ILog 定义在 SuperSocket 之中。
在你实现你你自己的 log factory之后,你需要在配置文件中启用它:
<superSocket logFactory="ConsoleLogFactory">
<servers>
<server name="EchoServer" serverTypeName="EchoService">
<listeners>
<add ip="Any" port="80" />
</listeners>
</server>
</servers>
<serverTypes>
<add name="EchoService"
type="SuperSocket.QuickStart.EchoService.EchoServer, SuperSocket.QuickStart.EchoService" />
</serverTypes>
<logFactories>
<add name="ConsoleLogFactory"
type="SuperSocket.SocketBase.Logging.ConsoleLogFactory, SuperSocket.SocketBase" />
</logFactories>
</superSocket>
标签:var type collect details ogg etl log4 space summary
原文地址:https://www.cnblogs.com/fanweisheng/p/11127075.html