Customize log4net to create logs daily, in date.filename format
book
Article ID: KB0080333
calendar_today
Updated On:
Spotfire Web Player
7.0 and lower
Show More
Show Less
Description
Users/customer may want to customize logging in Web Player to create daily logs for the various available logging categories in "log4net.config". We have taken "Spotfire.Dxp.Web.log" as an example in this article.
Issue/Introduction
Details to help you customize log4net to create daily logs in date.filename format
Environment
All supported Windows operating systems
Resolution
- Browse to the "<Web Player installation folder>\webroot\app_data" folder. - In an XML editor, locate and open the file "log4net.config". Be sure to create a back-up before editing. *** Default setting: ---------------------------------------------------------------------------------------------------------------------------------------------- <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <PreserveLogFileNameExtension value="true"/> <file value="<Web Player installation folder>\Logfiles\Spotfire.Dxp.Web.log"/> <appendToFile value="true"/> <rollingStyle value="Size"/> <maxSizeRollBackups value="4"/> <maximumFileSize value="500MB"/> <staticLogFileName value="false"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%-5level %date [%property{sessionId}, %property{pid}, %thread, %property{user}] %logger - %message%newline"/> </layout> <filter type="log4net.Filter.LoggerMatchFilter"> <param name="AcceptOnMatch" value="false"/> <param name="LoggerToMatch" value="WebLogger."/> </filter> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="INFO"/> <acceptOnMatch value="true"/> </filter> </appender> -------------------------------------------------------------------------------------------------------------------------------------------------- - Add the following tags. <datePattern value="dd.MM.yyyy'.Spotfire.Dxp.Web.log'" /> <rollingStyle value="Date"/> - Sample after making the changes. -------------------------------------------------------------------------------------------------------------------------------------------------- <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <PreserveLogFileNameExtension value="true"/> <file value="C:\Program Files\TIBCO\Spotfire Web Player\7.0.1\Logfiles\"/> <datePattern value="dd.MM.yyyy'.Spotfire.Dxp.Web.log'" /> <appendToFile value="true"/> <rollingStyle value="Date"/> <maxSizeRollBackups value="4"/> <maximumFileSize value="100MB"/> <staticLogFileName value="false"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%-5level %date [%property{sessionId}, %property{pid}, %thread, %property{user}] %logger - %message%newline"/> </layout> <filter type="log4net.Filter.LoggerMatchFilter"> <param name="AcceptOnMatch" value="false"/> <param name="LoggerToMatch" value="WebLogger."/> </filter> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="INFO"/> <acceptOnMatch value="true"/> </filter> </appender> -------------------------------------------------------------------------------------------------------------------------------------------------- - Save the file "log4net.config" and restart IIS/Web Player application pool for the changes to take effect.
Additional Information
https://stackoverflow.com/questions/31803537/log4net-rolling-daily-format-of-filename-with-date
Feedback
thumb_up
Yes
thumb_down
No