logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ibakirov@viakz.com" <ibaki...@viakz.com>
Subject AppendToFile resets to False when log file rolled
Date Fri, 04 Feb 2011 08:58:52 GMT

Using log4net: 1.2.10.0

Found strange behavior in appendToFile property when RollingFileAppender 
is used. If appendToFile=True in configuration and when daily roll event 
fired, property append for the new file gets false. Internal debug is 
enabled.

If you look you will find that: log4net: FileAppender: Opening file for 
writing [C:\Applications\Starter\logs\info.log_04-02-2011] append [True] 
(this is correct) and when file rolling happens new file created but 
append gets false: log4net: FileAppender: Opening file for writing 
[C:\Applications\Starter\logs\info.log_05-02-2011] append [False]. Is 
this right behavior?

So according to SDK: If the value is set to false then the file will be 
overwritten, if it is set to true then the file will be appended to. The 
default value is true.

I tested it with setting time to 23:58 and executed my application, 
waited for 3-5 minutes.

Internal debug:
#########################################################
log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
log4net: XmlHierarchyConfigurator: Retrieving an instance of 
log4net.Repository.Logger for logger [XPressLoggerError].
log4net: XmlHierarchyConfigurator: Setting [XPressLoggerError] 
additivity to [True].
log4net: XmlHierarchyConfigurator: Logger [XPressLoggerError] Level 
string is [ALL].
log4net: XmlHierarchyConfigurator: Logger [XPressLoggerError] level set 
to [name="ALL",value=-2147483648].
log4net: XmlHierarchyConfigurator: Loading Appender 
[RollingLogFileAppenderError] type: [log4net.Appender.RollingFileAppender]
log4net: XmlHierarchyConfigurator: Setting Property [File] to String 
value [logs\\error.log]
log4net: XmlHierarchyConfigurator: Setting Property [LockingModel] to 
object [log4net.Appender.FileAppender+MinimalLock]
log4net: XmlHierarchyConfigurator: Setting Property [AppendToFile] to 
Boolean value [True]
log4net: XmlHierarchyConfigurator: Setting Property [RollingStyle] to 
RollingMode value [Date]
log4net: XmlHierarchyConfigurator: Setting Property [DatePattern] to 
String value [_dd-MM-yyyy]
log4net: XmlHierarchyConfigurator: Setting Property [StaticLogFileName] 
to Boolean value [False]
log4net: PatternParser: Converter [message] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [ConversionPattern] 
to String value 
[===================================================================%n%-5p 
%d - %m%n%n]
log4net: PatternParser: Converter [literal] Option 
[===================================================================] 
Format [min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [p] Option [] Format 
[min=5,max=2147483647,leftAlign=True]
log4net: PatternParser: Converter [literal] Option [ ] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [d] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ - ] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [m] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object 
[log4net.Layout.PatternLayout]
log4net: RollingFileAppender: Type = [0], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [1], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [2], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [3], r0 = [_01-01-1970], r1 = 
[_02-01-1970]
log4net: RollingFileAppender: Searched for existing files in 
[C:\Applications\Starter\logs]
log4net: RollingFileAppender: curSizeRollBackups starts at [0]
log4net: FileAppender: Opening file for writing 
[C:\Applications\Starter\logs\error.log_04-02-2011] append [True]
log4net: XmlHierarchyConfigurator: Created Appender 
[RollingLogFileAppenderError]
log4net: XmlHierarchyConfigurator: Adding appender named 
[RollingLogFileAppenderError] to logger [XPressLoggerError].
log4net: XmlHierarchyConfigurator: Retrieving an instance of 
log4net.Repository.Logger for logger [XPressLoggerInfo].
log4net: XmlHierarchyConfigurator: Setting [XPressLoggerInfo] additivity 
to [True].
log4net: XmlHierarchyConfigurator: Logger [XPressLoggerInfo] Level 
string is [ALL].
log4net: XmlHierarchyConfigurator: Logger [XPressLoggerInfo] level set 
to [name="ALL",value=-2147483648].
log4net: XmlHierarchyConfigurator: Loading Appender 
[RollingLogFileAppenderInfo] type: [log4net.Appender.RollingFileAppender]
log4net: XmlHierarchyConfigurator: Setting Property [File] to String 
value [logs\\info.log]
log4net: XmlHierarchyConfigurator: Setting Property [LockingModel] to 
object [log4net.Appender.FileAppender+MinimalLock]
log4net: XmlHierarchyConfigurator: Setting Property [AppendToFile] to 
Boolean value [True]
log4net: XmlHierarchyConfigurator: Setting Property [RollingStyle] to 
RollingMode value [Date]
log4net: XmlHierarchyConfigurator: Setting Property [DatePattern] to 
String value [_dd-MM-yyyy]
log4net: XmlHierarchyConfigurator: Setting Property [StaticLogFileName] 
to Boolean value [False]
log4net: PatternParser: Converter [message] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [ConversionPattern] 
to String value 
[===================================================================%n%-5p 
%d - %m%n%n]
log4net: PatternParser: Converter [literal] Option 
[===================================================================] 
Format [min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [p] Option [] Format 
[min=5,max=2147483647,leftAlign=True]
log4net: PatternParser: Converter [literal] Option [ ] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [d] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ - ] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [m] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [n] Option [] Format 
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object 
[log4net.Layout.PatternLayout]
log4net: RollingFileAppender: Type = [0], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [1], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [2], r0 = [_01-01-1970], r1 = 
[_01-01-1970]
log4net: RollingFileAppender: Type = [3], r0 = [_01-01-1970], r1 = 
[_02-01-1970]
log4net: RollingFileAppender: Searched for existing files in 
[C:\Applications\Starter\logs]
log4net: RollingFileAppender: curSizeRollBackups starts at [0]
log4net: FileAppender: Opening file for writing 
[C:\Applications\Starter\logs\info.log_04-02-2011] append [True]
log4net: XmlHierarchyConfigurator: Created Appender 
[RollingLogFileAppenderInfo]
log4net: XmlHierarchyConfigurator: Adding appender named 
[RollingLogFileAppenderInfo] to logger [XPressLoggerInfo].
log4net: XmlHierarchyConfigurator: Hierarchy Threshold []
log4net: Logger: No appenders could be found for logger 
[XPressLoggerDebug] repository [log4net-default-repository]
log4net: Logger: Please initialize the log4net system properly.
log4net: Logger:    Current AppDomain context information:
log4net: Logger:       BaseDirectory   : C:\Applications\Starter\
log4net: Logger:       FriendlyName    : Starter.exe
log4net: Logger:       DynamicDirectory:
log4net: FileAppender: Opening file for writing 
[C:\Applications\Starter\logs\info.log_05-02-2011] append [False]



Here is my log4net.config:
############################

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

<log4net debug="true">

<appender name="RollingLogFileAppenderError" 
type="log4net.Appender.RollingFileAppender">
<file value="logs\\error.log" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="_dd-MM-yyyy" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern 
value="===================================================================%n%-5p 
%d - %m%n%n" />
</layout>
</appender>
<logger name="XPressLoggerError">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppenderError" />
</logger>

<appender name="RollingLogFileAppenderInfo" 
type="log4net.Appender.RollingFileAppender">
<file value="logs\\info.log" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="_dd-MM-yyyy" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern 
value="===================================================================%n%-5p 
%d - %m%n%n" />
</layout>
</appender>
<logger name="XPressLoggerInfo">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppenderInfo" />
</logger>

</log4net>
</configuration>




Mime
View raw message