使用以下配置即時通訊。這會爲每毫秒創建一個日誌文件。 我想每次執行只有一個日誌文件,它應該是時間戳記我不想讓nlog爲每個毫秒創建日誌文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="File" fileName="C:\log\log- ${date:format=dd/MM/yyyy HH\:mm\:ss}.txt"></target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
「每次執行一個日誌文件」。這是一個可執行程序,您正在運行還是Web服務器?什麼是執行的上下文。另外,您是否爲每個類創建1個靜態記錄器對象,並且整個執行過程將從該對象的單個實例運行? –