I use a recorder in my application to write to files. The source, switch, and listeners were defined in the app.config file as 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, my .cs code, I use the logger as follows:
private static TraceSource logger = new TraceSource("LoggerApp"); logger.TraceEvent(TraceEventType.Information, 1, "{0} : Started the application", DateTime.Now);
What do I need to do to create a new log file every day, and not write to the same log file every time?
source share