当前位置:才华咖 > 互联网计算机 > IT认证 > ACCP > 关于Log4net工程使用备忘
手机版

关于Log4net工程使用备忘

来源:才华咖 阅读:4.99K 次

为了方便广大计算机爱好者,下面是小编整理的关于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类型

本文链接:https://www.caihuaka.com/itrz/accp/d2ov7q.html

Copyright © 2024. 才华咖 All right reserved. 浙ICP备20120231号-3

文字美图素材,版权属于原作者。部分文章内容由网友提供推送时因种种原因未能与原作者联系上,若涉及版权问题,敬请原作者联系我们,立即处理。