# NLog

## NLog

官網:([http://nlog-project.org/](http://nlog-project.org/))

參考資料:([https://dotblogs.com.tw/jwpl102216/2017/03/26/090338](https://dotblogs.com.tw/jwpl102216/2017/03/26/090338))

參考資料:([https://dotblogs.com.tw/stanley14/2017/02/15/nlog](https://dotblogs.com.tw/stanley14/2017/02/15/nlog))

### 前置

1.NuGet 去取得 NLog Configuration 安裝

(詳請請看參考資料)

### 使用

1.先using using NLog;

2.產生拿來用的物件 private static Logger log = NLog.LogManager.GetCurrentClassLogger();

3.使用 log.Error("test");

### 用NLOG紀錄Exception

參考資料:([https://dotblogs.com.tw/wadehuang36/2012/07/11/nlog-exception](https://dotblogs.com.tw/wadehuang36/2012/07/11/nlog-exception))

參考資料:([http://knightcodes.com/.net/2016/05/25/logging-to-a-database-wth-nlog.html](http://knightcodes.com/.net/2016/05/25/logging-to-a-database-wth-nlog.html))

## 將NLOG存到資料庫

[https://github.com/nlog/NLog/wiki/Database-target](https://github.com/nlog/NLog/wiki/Database-target)

[https://stackoverflow.com/questions/17188478/how-do-i-configure-nlog-to-write-to-a-database](https://stackoverflow.com/questions/17188478/how-do-i-configure-nlog-to-write-to-a-database)

[http://kevintsengtw.blogspot.tw/2011/10/nlog-advanced-net-logging-2.html](http://kevintsengtw.blogspot.tw/2011/10/nlog-advanced-net-logging-2.html)
