- 下載Log4Net
http://logging.apache.org/log4net/download.html - 解開,在專案中加入參考
- 設定好config.xml (範例可google一下)
- 加入
using log4net;
using log4net.Config - 取得config.xml,類似以下範例
XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("config.xml"))); - 宣告 (ClassName替換成使用中的Class)
private static readonly ILog log = LogManager.GetLogger(typeof(ClassName)); - Done!
全站熱搜