关于Log4net工程使用备忘

为了方便广大计算机爱好者,下面是小编整理的关于Log4net工程中的使用备忘,欢迎参考!

关于Log4net工程使用备忘

(1):引用log4net

(2):using log4net;

(3):构造函数中

static CoreLogging()

{

igure();

}

(4):private const string UnknownDeviceCategory = "UnknownDevice";

private const string AlarmCategory = "Alarm";

private const string GeneralCategory = "Trace";

private const string ScriptCategory = "Script";

private const string ConfigCategory = "Config";

private const string ScanCategory = "Scan";

private const string UdpCategory = "UdpSender";

private const string MessageMergeCategory = "MessageMerge";

private static ILog traceLog = ogger(GeneralCategory);

private static ILog scriptLog = ogger(ScriptCategory);

private static ILog configLog = ogger(ConfigCategory);

private static ILog scanLog = ogger(ScanCategory);

private static ILog messageMergeLog = ogger(MessageMergeCategory);

private static ILog udpLog = ogger(UdpCategory);

private static ILog alarmLog = ogger(AlarmCategory);

private static ILog unknownDeviceLog = ogger(UnknownDeviceCategory);

private static void Log(ILog logger, Object message, Priority priority)

{

switch (priority)

{

case G:

g(message);

break;

case :

(message);

break;

case :

(message);

break;

case R:

r(message);

break;

case L:

l(message);

break;

}

}

public static void LogMessageMergeLog(object message, Priority priority)

{

Log(messageMergeLog, message, priority);

}

///

/// 通过Udp发送日志

///

/// 要发送的.消息内容

/// 优先级

public static void SendLogViaUdp(object message, Priority priority)

{

Log(udpLog, message, priority);

}

其他的略。

配置文件中需要配置如下

其他略

下面为各个动作。Trace类型