c# - Writing to a new log file each day with TraceSource -
i using logger in application write files. source, switch , listeners have been defined in app.config file follows:
<system.diagnostics> <sources> <source name="loggerapp" switchname="sourceswitch" switchtype="system.diagnostics.sourceswitch"> <listeners> <add name="mylistener" type="system.diagnostics.textwritertracelistener" initializedata="mylistener.log" /> </listeners> </source> </sources> <switches> <add name="sourceswitch" value="information" /> </switches> </system.diagnostics> inside, .cs code, use logger follows:
private static tracesource logger = new tracesource("loggerapp"); logger.traceevent(traceeventtype.information, 1, "{0} : started application", datetime.now); what have create new log file each day instead of writing same log file every time?
what have create new log file each day instead of writing same log file every time?
you'd have make own tracelistener instead of using textwritertracelistener. allow tracelistener implementation change log files daily, or other custom behavior wish.
Comments
Post a Comment