Write Logs

NLog

Setup steps

  • Install NLog
  • Install NLog.Config
  • 設定NLog.Config檔案中,Target的參數及Rules的區塊
  • Add Log Service class
using NLog;
public class LogService
{
    public static Logger logger = LogManager.GetCurrentClassLogger();
}
LogService.logger.Info("User Login = " + userAccount);

Useful Resources

http://kevintsengtw.blogspot.tw/2011/10/nlog-advanced-net-logging-1.html

Q&A

Tips: https://github.com/NLog/NLog/wiki/Logging-troubleshooting

<nlog throwExceptions="true">
   ...
</nlog>

Q1: Access is denied

Solution :

Action: Add "Network Service" or "ApplicationPoolIdenitty" account have an access authority

Target folder: logs folder

Remark: The account was decied by Application Pools setting

Ref: https://blog.miniasp.com/post/2009/09/09/Introduce-IIS-75-Application-Pool-Identity-and-Virtual-Account.aspx

results matching ""

    No results matching ""