You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by "Conant, Patrick D" <pa...@hp.com> on 2005/05/27 18:48:44 UTC

Using machine.config for log4net configuration

I'm trying to create central log4net configuration settings for multiple
.NET components running on a single machine.  I thought I'd be able to
do this by putting log4net.dll in the GAC and adding log4net config
settings in the machine.config file.  However, my web services still
look for log4net configuration in the web.config files.  When I add
"log4net.Internal.Debug" to the web.config file, the output is:

log4net: log4net assembly [log4net, Version=1.2.9.0, Culture=neutral,
PublicKeyToken=b32731d11ce58905]. Loaded from [Global Assembly Cache].
(.NET Runtime [1.1.4322.2032] on Microsoft Windows NT 5.1.2600.0)
log4net: DefaultRepositorySelector: defaultRepositoryType
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Creating repository for assembly
[MyApp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null]
log4net: DefaultRepositorySelector: Assembly [MyApp, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=null] Loaded From
[c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net
files\receiver\0dff92af\e29d3d6a\assembly\dl2\9d5072b7\60373264_d862c501
\MyApp.dll]
log4net: DefaultRepositorySelector: Assembly [MyApp, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=null] does not have a
RepositoryAttribute specified.
log4net: DefaultRepositorySelector: Assembly [MyApp, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=null] using repository
[log4net-default-repository] and repository type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Creating repository
[log4net-default-repository] using type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [C:/Work/main/MyApp/web.config]
watching for file updates
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file [C:/Work/main/MyApp/web.config]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using stream
log4net: XmlConfigurator: loading XML configuration
log4net: XmlConfigurator: XML configuration does not contain a <log4net>
element. Configuration Aborted.


When I put the add the "log4net.Internal.Debug" setting to the
machine.config, I don't get any debug output.  In my machine.config
file, I have the following sections:

<configuration>
  <configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net,
Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905" />
  </configSections>
<!-- ... -->
<log4net debug="true">
  <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
    <file value="C:\net.log.txt" />
    <appendToFile value="true" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="5MB" />
    <rollingStyle value="Size" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
  </layout>
  <root>
    <level value="DEBUG" />
    <appender-ref ref="RollingLogFileAppender" />
  </root>
</log4net>
</configuration>



Any advice on what I'm missing in order to allow central management of
logging in the machine.config file?  Any pointers would be appreciated.

Thanks,
Pat.