Question
1
Replies
121
Views
Standard Chartered Bank
Posted: November 12, 2019
Last activity: November 12, 2019
FileName in Runtime Log
Hi, i want to customize the Runtime Log FileName Ex:RuntimeDateTime.Log4Net. Please assist me.
Thanks,
Asvinth Saravanan
You can change the name of the file in the RuntimeConfig in the line listed below. The problem you will encounter is that you can't set the datetime as part of the name dynamically. I recommend creating a program that waits for the file to roll and rename when Runtime.Log4Net.txt.1 is created.
<publisher mode="on" trace_mode="on" exception_mode="on" assembly="OpenSpan" type="OpenSpan.Diagnostics.Publishers.Log4NetPublisher" InnerXml="<!-- Settings for Runtime Log4Net logging -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender, log4net">
 <!-- Name to save the log file to -->
 <file type="log4net.Util.PatternString" value="%property{ConfigurationDirectory}/%property{ProgramShortName}_Log4Net.txt" />
 <!-- Set whether to create a new file every run (backing up old ones) -->
 <appendToFile value="false" />
 <!-- Set the maximum size of each log file -->
 <rollingStyle value="Size" />
 <maximumFileSize value="10MB" />
 <!-- Maximum files to back up, will be named filename.1, filename.2, ..., filename.n -->
 <maxSizeRollBackups value="5" />
 <staticLogFileName value="true" />
 <!-- Allow multiple instances to log to the same file -->
 <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
 <layout type="log4net.Layout.PatternLayout">
 <conversionPattern value="%-5level | %date | %7.7thread | %message%newline" />
 </layout>
</appender>
<root>
 <!-- You can enter ERROR, WARN, INFO, DEBUG, ALL, or OFF. ALL and DEBUG provide the same results. FATAL means nothing will be logged. -->
 <level value="DEBUG" />
 <appender-ref ref="RollingFileAppender" />
</root>," />