I was making these changes you suggested and somehow everything started working. I don't even know what I did :-(, if I remove your internal logging config entries, it still works. I must have had something out of sync on the box I was deploying changes to.
Weird thing now is that the log entries appear out of order, but at least I'm getting them all. Thanks for your response. -----Original Message----- From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 17, 2007 6:14 PM To: Log4NET User Subject: Re: Cannot create log from vb.net class library .dll I'd recommend turning on internal log4net logging. It may be because your FileAppender is attempting to write to '\windows\system32\GenericInterface.log' instead of where you really want it to. Adding this code to your App.Config will tell log4net to log its internal errors to System.Diagnostics.Trace which will be captured to a file: <appSettings> <add key="log4net.Internal.Debug" value="true" /> </appSettings> <system.diagnostics> <trace autoflush="true"> <listeners> <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\\log4net.txt" /> </listeners> </trace> </system.diagnostics> ----- Original Message ---- From: "Dahl, Scott (CMA Consulting)" <[EMAIL PROTECTED]> To: [email protected] Sent: Tuesday, April 17, 2007 5:55:08 PM Subject: Cannot create log from vb.net class library .dll Here's a stripped down version of the current class library dll code: Imports System.IO ' We want this assembly to have a seperate logging repository to the ' rest of the application. We will configure this repository seperatly. '<Assembly: log4net.Config.AliasRepository("trafficRouter.trafficRouter")> '<Assembly: log4net.Config.XmlConfigurator(Watch:=True)> Public Class trafficRouter Private db As New dbConnection ' Create a logger for use in this class Private Shared ReadOnly l As log4net.ILog = log4net.LogManager.GetLogger("default") Public Sub New() Try log4net.Config.XmlConfigurator.Configure() 'log4net.Config.XmlConfigurator.ConfigureAndWatch(New FileInfo("c:\\ xyz.config")) l.Info("Creating Traffic Router.") dbConnect() l.Info("Done creating Traffic Router.") Catch ex As Exception l.Error(ex) End Try End Sub End Class This is the web.config file for the web service which is logging correctly: <?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0";> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" /> </configSections> <appSettings/> <!-- This section contains the log4net configuration settings --> <log4net> <!-- Define some output appenders --> <appender name="LogFileAppender" type="log4net.Appender.FileAppender"> <file value=".\\GenericInterface.log" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> <logger name="default"> <level value="ALL" /> <appender-ref ref="LogFileAppender" /> </logger> </log4net> <connectionStrings/> <system.web> <compilation debug="false" /> <authentication mode="Windows" /> </system.web> </configuration> Here is the "custom config" I tried using for the class library log: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <sources> <!-- This section defines the logging configuration for My.Application.Log --> <source name="DefaultSource" switchName="DefaultSwitch"> </source> </sources> <switches> <add name="DefaultSwitch" value="Information" /> </switches> </system.diagnostics> <!-- Register a section handler for the log4net section --> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <!-- This section contains the log4net configuration settings --> <log4net> <!-- Define some output appenders --> <appender name="LogFileAppender" type="log4net.Appender.FileAppender"> <file value=".\\trafficRouter.log" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> <logger name="default"> <level value="ALL" /> <appender-ref ref="LogFileAppender" /> </logger> </log4net> </configuration> I've come across a few suggestions but none of those have helped at all. This is what I've tried different from the current code: 1) Explicitly call the log4net.Config.XmlConfigurator.ConfigureAndWatch function, passing my custom configuration above, in the constructor. 2) Setting an alias repository using: Assembly: log4net.Config.AliasRepository("trafficRouter.trafficRouter")> and Assembly: log4net.Config.AliasRepository("trafficRouter")> 3) Uncommenting the other assembly line from the class. I'm pretty new to .net and log4net so please excuse me if I've stumbled with some terminology or overlooked the obvious. Thanks, Scott
