wzp
2021-07-28 864986e4cad03f6b9bba9a7e65379db496b62a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
 
namespace AsiaINFO.SMS.DBFactory
{
    public class log4netService
    {
        static log4netService()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "log4net.config";
            log4net.Config.XmlConfigurator.Configure(new FileInfo(path));
        }
 
        public static log4net.ILog GetLog(string logName)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(logName);
            return log;
        }
        private static string DefaultLoggerName = "RollingFileLog";
        public static void Debug(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(DefaultLoggerName);
            if (log.IsDebugEnabled)
            {
                log.Debug(message);
            }
            log = null;
        }
        public static void Info(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(DefaultLoggerName);
            if (log.IsInfoEnabled)
            {
                log.Info(message);
            }
            log = null;
        }
        public static void Error(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(DefaultLoggerName);
            if (log.IsErrorEnabled)
            {
                log.Error(message);
            }
            log = null;
        }
        public static void Warm(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(DefaultLoggerName);
            if (log.IsWarnEnabled)
            {
                log.Warn(message);
            }
            log = null;
        }
    }
}