can I pass a custom property to NLOG and output to file?

前端 未结 4 1010
囚心锁ツ
囚心锁ツ 2021-02-06 05:43

EDIT 4: \"From\" seems to be a reserved word in NLog. Changing it \"FromID\" worked. this is an awesome way to pass variables to NLog and still keep your code clean !!!! TH

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-06 06:14

    NLog 4.5 supports structured logging using message templates:

    logger.Info("Logon by {user} from {ip_address}", "Kenny", "127.0.0.1");
    

    See also https://github.com/NLog/NLog/wiki/How-to-use-structured-logging

提交回复
热议问题