Yes, it is possible. I have this requirement in dll - COM service, which
has no EXE entry point. You must to manually call
Config.XmlConfigurator.ConfigureAndWatch(New
FileInfo(KasaInstLog4NetConfigFile)) at the time of DLL inicialization.
For other dll you must create AliasRepository attributes (see log4net
examples).
<Assembly: AliasRepository("Anete.Devices")>
<Assembly: AliasRepository("Anete.Kasa8.Common")>
---------
VB.NET, VS2005 Pro, XP Pro/P4 3GHz, 2GB RAM
___________________________________________________
Karel Kral, vyvojar
ANETE, s.r.o.
___________________________________________________
On 23.2.2007 12:03, Hans-Theo Jungeblut wrote:
> HI Fiala,
> Thanks for your response.
>
> The problem is, I will do not want to configure the .exe.conf of the
> application, as I produce only library DLLs used by other developers within
> their applications.
>
> Moreover, as it is described in the log4net documentation as I understood it,
> it is possible to configure log4net on the DLL not the application base.
>
> Any suggestions?
>
> 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:[EMAIL PROTECTED]
> Sitz der Gesellschaft: 32657 Lemgo
> USt-IDNr.: DE 811281939
> Amtsgericht Lemgo, HRB Lemgo 1805
>
> Geschäftsführer / Managing Director
> Andreas Orzelski
>
>
> -----Ursprüngliche Nachricht-----
> Von: Dean Fiala [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 22. Februar 2007 10:12
> An: 'Log4NET User'
> Betreff: RE: Problem if Log4Net is used in to different DLLs within a project
>
> 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
> information.
>
> HTH,
>
> Dean Fiala
>
> Chief Technology Officer
> Celadon Laboratories, Inc.
> http://www.celadonlabs.com
>
>
>
> -----Original Message-----
> From: Hans-Theo Jungeblut [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 22, 2007 3:41 PM
> To: [email protected]
> Subject: Problem if Log4Net is used in to different DLLs within a project
>
> Hallo,
>
> I am having an application, WindowsForms .NET 2.0, which uses different
> DLLs.
> 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,
> Theo
>
> Technical details of the setup:
> ------------------------------------------------------
> Log4Net version: 1.2.10.0
> 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" ?>
> <log4net>
> <!-- Trace is set to be a TraceAppender --> <appender name="Trace"
> type="log4net.Appender.TraceAppender">
> <!-- Trace uses PatternLayout -->
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%date{ISO8601} [%t] - [%p] - %message
> %newline" />
> </layout>
> </appender>
>
> <appender name="FileAppenderResources"
> type="log4net.Appender.FileAppender">
> <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" />
> </layout>
> </appender>
>
> <appender name="FileAppenderContainer"
> type="log4net.Appender.FileAppender">
> <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" />
> </layout>
> </appender>
>
> <appender name="Event" type="X.MyLogger.EventAppender">
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%date{ABSOLUTE} [%t] - %message" />
> </layout>
> </appender>
> <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
> <param name="RemoteAddress" value="127.0.0.1" />
> <param name="RemotePort" value="18780" />
> <layout type="log4net.Layout.XmlLayout">
> <param name="Prefix" value="" />
> </layout>
> </appender>
>
> <!-- Set root logger level to DEBUG and its only appender to Trace -->
> <root>
> <level value="INFO" />
> <appender-ref ref="Event" />
> <appender-ref ref="FileAppenderContainer" />
> <appender-ref ref="Trace" />
> <appender-ref ref="UdpAppender" />
> </root>
> <logger name="X.W.Q">
> <level value="INFO" />
> </logger>
>
> <logger name="X.W.Q.A">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.D">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.S.A">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.S.S">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.S.D">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.S.F">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.S.G">
> <level value="INFO" />
> </logger>
> <logger name="X.W.Q.S.Q">
> <level value="INFO" />
> </logger>
>
> <logger name="X.W.Q.T">
> <level value="WARN" />
> </logger>
>
> <logger name="X.W.Q.R">
> <level value="WARN" />
> </logger>
> <logger name="X.W.Q.U">
> <level value="WARN" />
> </logger>
>
> <logger name="X.W.Q.Log4NetWrapper">
> <level value="ERROR" />
> <appender-ref ref="FileAppenderResources" /> </logger>
> <configuration>
> <appSettings>
> <add key="log4net.Internal.Debug" value="true"/>
> </appSettings>
> </configuration>
>
> </log4net>
>
>
> 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:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
> Sitz der Gesellschaft: 32657 Lemgo
>
> USt-IDNr.: DE 811281939
>
> Amtsgericht Lemgo, HRB Lemgo 1805
>
>
>
> Geschäftsführer / Managing Director
> Andreas Orzelski
>
>
>
>
>
>