logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Fiala" <dfi...@celadonlabs.com>
Subject RE: Problem if Log4Net is used in to different DLLs within a project
Date Thu, 22 Feb 2007 21:12:02 GMT
You have to configure the application for logging -- not the dlls.  Dlls are
run in the context of the calling application, they are not autonomous.
You'd have the same problem trying to read any .NET configuration file. 

Set up your WinForms application to read the log4net configuration from its
own config file and any dlls it is using will use that configuration


Dean Fiala

Chief Technology Officer
Celadon Laboratories, Inc.


-----Original Message-----
From: Hans-Theo Jungeblut [mailto:tjungeblut@kw-software.de] 
Sent: Thursday, February 22, 2007 3:41 PM
To: log4net-user@logging.apache.org
Subject: Problem if Log4Net is used in to different DLLs within a project


I am having an application, WindowsForms .NET 2.0, which uses different
Everything is working as long as I use Log4Net just within one DLL.

Trying to use Log4Net with 2 or more DLLs by using a DLLName.dll.config file
for each DLL, configured within the AssemblyInfo.cs result in not having any
logging output.
Moreover, just using Log4Net within 2 different DLL with having just 1 DLL
set up with a config file, but both DLL including logger calls result in the
same result.
Does anyone of a solution for this problem,as I was not able to find any
information in the mailing list.
Thx in advance!
Greetings from Germany,

Technical details of the setup:
Log4Net version:
Assembly type:    DLL
Application type: WindowsForms
Platform:         MS .NET 2.0

Setup in AssemblyInfo.cs:
// Configure log4net using the .log4net file // This will cause log4net to
look for a configuration file // called x.log4net in the application base //
directory (i.e. the directory containing x) // The config file will be
watched for changes.
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "config",
Watch = true)]
DLL.Configuration file (basically the same content just diffenent logger
names ):
<?xml version="1.0" encoding="utf-8" ?>
 <!-- Trace is set to be a TraceAppender -->  <appender name="Trace"
  <!-- Trace uses PatternLayout -->
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date{ISO8601} [%t] - [%p] - %message
%newline" />
  <appender name="FileAppenderResources"
  <file value="MissingResourceEntries.log" />
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date{HH:mm:ss} - %message %newline" />
  <appender name="FileAppenderContainer"
  <file value="DLLName.log" />
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date{ISO8601} [%t] - %message  %newline" />
  <appender name="Event" type="X.MyLogger.EventAppender">
    <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date{ABSOLUTE}  [%t] -  %message" />
  <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <param name="RemoteAddress" value="" />
    <param name="RemotePort" value="18780" />
    <layout type="log4net.Layout.XmlLayout">
      <param name="Prefix" value="" />
 <!-- Set root logger level to DEBUG and its only appender to Trace -->
  <level value="INFO" />
    <appender-ref ref="Event" />
    <appender-ref ref="FileAppenderContainer" />
    <appender-ref ref="Trace" />
    <appender-ref ref="UdpAppender" />
  <logger name="X.W.Q">
    <level value="INFO" />
  <logger name="X.W.Q.A">
  <level value="WARN" />
  <logger name="X.W.Q.D">
    <level value="WARN" />
  <logger name="X.W.Q.S.A">
    <level value="WARN" />
  <logger name="X.W.Q.S.S">
    <level value="WARN" />
  <logger name="X.W.Q.S.D">
    <level value="WARN" />
  <logger name="X.W.Q.S.F">
    <level value="WARN" />
  <logger name="X.W.Q.S.G">
    <level value="INFO" />
  <logger name="X.W.Q.S.Q">
    <level value="INFO" />
  <logger name="X.W.Q.T">
  <level value="WARN" />
  <logger name="X.W.Q.R">
    <level value="WARN" />
  <logger name="X.W.Q.U">
    <level value="WARN" />
 <logger name="X.W.Q.Log4NetWrapper">
  <level value="ERROR" />
  <appender-ref ref="FileAppenderResources" />  </logger>
      <add key="log4net.Internal.Debug" value="true"/>

Mit freundlichen Grüßen / best regards

Dipl. Inform. (FH) Hans-Theo Jungeblut
Development Automation Framework / FDT

KW-Software GmbH
Lagesche Strasse 32
32657 Lemgo
Deutschland / Germany

Phone: +49 5261 9373-57
Fax: +49 5261 9373-26

Homepage: www.kw-software.com
mailto:tjungeblut@kw-software.com <mailto:tjungeblut@kw-software.com>  

Sitz der Gesellschaft: 32657 Lemgo

USt-IDNr.: DE 811281939

Amtsgericht Lemgo, HRB Lemgo 1805


Geschäftsführer / Managing Director
Andreas Orzelski

View raw message