简体   繁体   中英

Multiple Log Files using NLog

I have a use case for NLog where I'd like to have the ability to have multiple Logfiles according to the operation I'm executing at the server.

I've decided to go with NLog for logging but I'm a bit lost at how I'm going to have different files using the configuration file.

Ideally, this would all be done via the configuration API which seemed the most configurable.

This is also a project on which we intend to build a dll file to be able to import on 3 different platforms (thus the need for log files flexibility).

Could anyone experienced with Nlog be able to provide an example of a multi-logfile configuration? Maybe something where the constructor receives the LogManager as a parameter?

Anyone had this requirement before?

Best Regards

This a really a common used case. You can use layout renderers in the file name, like filename=${loggername} . See also https://github.com/NLog/NLog/wiki/File-target#per-level-log-files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM