[
https://issues.apache.org/jira/browse/LOG4NET-119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Bodewig updated LOG4NET-119:
-----------------------------------
Fix Version/s: 1.2 Maintenance Release
> XML configuration: update="Merge" does not work as expected
> -----------------------------------------------------------
>
> Key: LOG4NET-119
> URL: https://issues.apache.org/jira/browse/LOG4NET-119
> Project: Log4net
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2.10
> Environment: Microsoft .NET Framework 2.0
> Reporter: Patrick Gautschi
> Priority: Minor
> Fix For: 1.2 Maintenance Release
>
>
> To avoid a mandatory xml configuration file, I embeded it into the application
> reading it with XmlConfigurator.Configure(Stream).
> To allow the logging configuration to be changed when required, I also
> read the now optional .config file of the application using
> XmlConfigurator.Configure();
> A minor problem is that when no log4net is specified in the .config file I get
> the following error:
> log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net'
> in the application's .config file. Check your .config file for the <log4net>
> and <configSections> elements. The configuration section should look like:
> <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
> There is a simple workaround (when not watching the file for changes):
> if (System.Configuration.ConfigurationManager.GetSection("log4net") !=
> null) {
> XmlConfigurator.Configure();
> }
> But the real problem is, that I have to include the whole configuration into
> the .config file, not just the changed parts even though using update="Merge".
> As an example:
> The embeded configuration looks like this
> <log4net>
> <appender name="ErrorFile" type="log4net.Appender.RollingFileAppender">
> <threshold value="WARN" />
> <file value="somepath/error.log" />
> <appendToFile value="true" />
> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
> <encoding value="utf-8" />
> <countDirection value="1" />
> <maximumFileSize value="100KB" />
> <maxSizeRollBackups value="2" />
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%utcdate{yyyy-MM-dd HH:mm:ss.ff}Z [%thread]
> %-5level %logger [%ndc]%newline %message%newline" />
> </layout>
> </appender>
> <appender name="InfoFile" type="log4net.Appender.RollingFileAppender">
> <file value="somepath/info.log" />
> <appendToFile value="false" />
> <encoding value="utf-8" />
> <countDirection value="1" />
> <maximumFileSize value="1MB" />
> <maxSizeRollBackups value="3" />
> <!--<staticLogFileName value="false" />-->
> <rollingStyle value="Size" />
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%utcdate{yyyy-MM-dd HH:mm:ss.ff}Z [%thread]
> %-5level %logger - %message%newline" />
> </layout>
> </appender>
> <root>
> <level value="WARN" />
> <appender-ref ref="ErrorFile" />
> <appender-ref ref="InfoFile" />
> </root>
> </log4net>
> I expected to be able to create an .config file like this to adjust the root
> level:
> <configuration>
> <configSections>
> <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
> </configSections>
> <log4net update="Merge">
> <root>
> <level value="DEBUG" />
> </root>
> </log4net>
> </configuration>
> However this removes the appenders from the root logger. Using
> <configuration>
> <configSections>
> <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
> </configSections>
> <log4net update="Merge">
> <root>
> <level value="DEBUG" />
> <appender-ref ref="ErrorFile" />
> <appender-ref ref="InfoFile" />
> </root>
> </log4net>
> </configuration>
> does not help either:
> log4net:ERROR XmlHierarchyConfigurator: No appender named [ErrorFile] could
> be found.
> log4net:ERROR XmlHierarchyConfigurator: Appender named [ErrorFile] not
> found.
> log4net:ERROR XmlHierarchyConfigurator: No appender named [InfoFile] could
> be found.
> log4net:ERROR XmlHierarchyConfigurator: Appender named [InfoFile] not found.
> I think the purpose of update="Merge" should be to avoid the repetition of
> all the lengthy appender definitions in the .config file.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira