2012-11-14 3 views
1

C# 2008 응용 프로그램에서 NLog 오류 로그 파일을 작성하여 파일에 날짜가 기록되도록하고 싶습니다. 아래에 나열된 예에서는 3 개의 로그 파일이 있음을 알 수 있습니다. 이 파일들에 월 - 일 형식을 어떻게 두는 지 말해 줄 수 있습니까? 당신의 fileName 매개 변수에 대한이 같은날짜가있는 nlog 파일

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<configSections> 
    <sectionGroup name="spring"> 
    <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" /> 
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /> 
    </sectionGroup> 
    <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:\Logs\NlogOutput.log" /> 
    </targets> 
    <rules> 
    <logger name="*" minlevel="Info" writeTo="logfile" /> 
    </rules> 
    </nlog> 

답변

0

사용 무언가 :

fileName="${basedir}/${shortdate}.log" 

는 일반적으로, 당신은 파일 이름을 구성하기 위해 가장 NLog의 LayoutRenderers를 사용할 수 있습니다.