Beispiel #1
0
        private static LoggingService CreateLogService(String logName, String logFolder, Int32 logGrade = 1, Boolean isStart = true)
        {
            var logKey = String.Format("{0}+{1}", logName, logFolder);
            if (LoggingServicePool.ContainsKey(logKey))
            {
                return LoggingServicePool[logKey];
            }
            if (LogManager.GetLogFormatter("TEXTLogFormatter") == null) LogManager.RegisterLogFormatter("TEXTLogFormatter", Logformartter);
            if (LogManager.GetLogFactory("TEXTLogFactory") == null) LogManager.RegisterLogFactory("TEXTLogFactory", LogFactory);

            var logCfg = new LogServiceConfig
            {
                LogFactoryName = "TEXTLogFactory",
                LogName = logName,
                LogSeperator = "|",
                LogFilePath = Application.StartupPath + "\\Log\\",
                LogSubFolder = logFolder,
                LogFileNameFormatter = logName + "|yyyyMMdd|M*5|_",
                LogType = @"TEXT",
                LogVersion = "1.0",
                LogFormatter = "TEXTLogFormatter",
                LogInfo = "",
                LogEnable = true,
                LogTraceEnable = true,
                LogGrade = logGrade,
                LogPersistInterval = 500,
                LogDescription = ""
            };

            var logService = LogManager.CreateLogService(logCfg);
            LoggingServicePool.Add(logKey, logService);
            if (isStart) logService.Start();
            return logService;
        }
Beispiel #2
0
 /// <summary>
 /// 创建日志服务
 /// </summary>
 /// <param name="logCfg">日志服务配置文件</param>
 protected LoggingService(LogServiceConfig logCfg)
 {
     DefaultPersistInterval = 300;
     LogRecordList = new List<LogRecord>();
     LogConfig = logCfg;
 }
Beispiel #3
0
 /// <summary>
 /// 获取日志工厂名称
 /// </summary>
 /// <param name="logCfg"></param>
 /// <returns></returns>
 public static string GetLogFactoryName(LogServiceConfig logCfg)
 {
     return logCfg.LogFactoryName;
 }
Beispiel #4
0
 /// <summary>
 /// 根据日志参数获取日志格式信息
 /// </summary>
 /// <param name="logCfg"></param>
 /// <returns></returns>
 public static LogFormatter GetLogFormatter(LogServiceConfig logCfg)
 {
     return GetLogFormatter(logCfg.LogFormatter);
 }
Beispiel #5
0
 /// <summary>
 /// 获取日志格式名称
 /// </summary>
 /// <param name="logCfg">日志配置信息</param>
 /// <returns></returns>
 public static string GetLogFormatterName(LogServiceConfig logCfg)
 {
     return logCfg.LogFormatter;
 }
Beispiel #6
0
 /// <summary>
 /// 根据日志配置创建日志服务
 /// </summary>
 /// <param name="logCfg">日志配置</param>
 /// <returns></returns>
 public virtual LoggingService CreateLogService(LogServiceConfig logCfg)
 {
     return null;
 }
Beispiel #7
0
 /// <summary>
 /// 根据日志配置文件创建日志服务
 /// </summary>
 /// <param name="logCfg"></param>
 /// <returns></returns>
 public static LoggingService CreateLogService(LogServiceConfig logCfg)
 {
     LoggingService logService;
     var logName = GetLogName(logCfg);
     var logFactoryName = GetLogFactoryName(logCfg);
     if (LogServiceDict.TryGetValue(logName, out logService))
     {
         return logService;
     }
     var logFactory = GetLogFactory(logFactoryName);
     return logFactory != null ? GetLogFactory(logFactoryName).CreateLogService(logCfg) : null;
 }
Beispiel #8
0
 /// <summary>
 /// 获取日志工厂名称
 /// </summary>
 /// <param name="logCfg"></param>
 /// <returns></returns>
 public static string GetLogFactoryName(LogServiceConfig logCfg)
 {
     return(logCfg.LogFactoryName);
 }
Beispiel #9
0
 /// <summary>
 /// 获取日志格式名称
 /// </summary>
 /// <param name="logCfg">日志配置信息</param>
 /// <returns></returns>
 public static string GetLogFormatterName(LogServiceConfig logCfg)
 {
     return(logCfg.LogFormatter);
 }
Beispiel #10
0
 /// <summary>
 /// 根据日志参数获取日志格式信息
 /// </summary>
 /// <param name="logCfg"></param>
 /// <returns></returns>
 public static LogFormatter GetLogFormatter(LogServiceConfig logCfg)
 {
     return(GetLogFormatter(logCfg.LogFormatter));
 }
Beispiel #11
0
 /// <summary>
 /// 根据日志配置创建日志服务
 /// </summary>
 /// <param name="logCfg">日志配置</param>
 /// <returns></returns>
 public virtual LoggingService CreateLogService(LogServiceConfig logCfg)
 {
     return(null);
 }
Beispiel #12
0
 /// <summary>
 /// 格式化日志记录
 /// </summary>
 /// <param name="logCfg">日志服务配置</param>
 /// <returns></returns>
 public virtual LogRecord FormatLogRecord(LogServiceConfig logCfg)
 {
     return null;
 }