The internal log is as follows: log4net: log4net assembly [log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821]. Loaded from [C:\Documents and Settings\Neil\My Documents\Visual Studio 2008\Projects\MatrixRoot\Matrix5\TestResults\Neil_DEVNH 2008-05-13 09_37_37\Out\log4net.dll]. (.NET Runtime [2.0.50727.1433] on Microsoft Windows NT 5.1.2600 Service Pack 2) log4net: DefaultRepositorySelector: defaultRepositoryType [log4net.Repository.Hierarchy.Hierarchy] log4net: DefaultRepositorySelector: Creating repository for assembly [MatrixBLL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=e634c78404aaff97] log4net: DefaultRepositorySelector: Assembly [MatrixBLL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=e634c78404aaff97] Loaded From [C:\Documents and Settings\Neil\My Documents\Visual Studio 2008\Projects\MatrixRoot\Matrix5\TestResults\Neil_DEVNH 2008-05-13 09_37_37\Out\MatrixBLL.dll] log4net: DefaultRepositorySelector: Assembly [MatrixBLL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=e634c78404aaff97] does not have a RepositoryAttribute specified. log4net: DefaultRepositorySelector: Assembly [MatrixBLL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=e634c78404aaff97] 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:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Log4Net.config] watching for file updates log4net: XmlConfigurator: configuring repository [log4net-default-repository] using file [C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Log4Net.config] log4net: XmlConfigurator: config file [C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Log4Net.config] not found. Configuration unchanged. log4net: DefaultRepositorySelector: Creating repository for assembly [MatrixDAL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=1c2dda121c43247c] log4net: DefaultRepositorySelector: Assembly [MatrixDAL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=1c2dda121c43247c] Loaded From [C:\Documents and Settings\Neil\My Documents\Visual Studio 2008\Projects\MatrixRoot\Matrix5\TestResults\Neil_DEVNH 2008-05-13 09_37_37\Out\MatrixDAL.dll] log4net: DefaultRepositorySelector: Assembly [MatrixDAL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=1c2dda121c43247c] does not have a RepositoryAttribute specified. log4net: DefaultRepositorySelector: Assembly [MatrixDAL, Version=5.1.1.7, Culture=neutral, PublicKeyToken=1c2dda121c43247c] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy] log4net: DefaultRepositorySelector: repository [log4net-default-repository] already exists, using repository type [log4net.Repository.Hierarchy.Hierarchy] log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository]
It seems that log4net isn't looking for (or finding) my log4net.config, which is in the test application executable folder - ie alongside the app executable. My AssemblyInfo.cs for both the main application project and the logging class project both have an XmlConfiguratorAttribute defined, eg [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] As I understand it, this tells log4net to look in the app base directory, which is where log4net.config is placed when the app is built. However, if I copy the log4net.config to the path specified in the trace above (ie c:\program files\Microsoft Visual studio 9\....\IDE\Log4Net.config) my logging works as required. So what do I need to do to get log4net to look in the right place for the config file? TIA Neil -----Original Message----- From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: 13 May 2008 05:31 To: Log4NET User Subject: Re: Problem getting Log4net to work What does log4net's internal debug message say: http://logging.apache.org/log4net/release/faq.html Have you tried configuring log4net from within the client app's entry point to verify your log4net.config is correct? ----- Original Message ---- From: Neil Haughton <[EMAIL PROTECTED]> To: Log4NET User <log4net-user@logging.apache.org> Sent: Monday, May 12, 2008 11:26:00 AM Subject: Problem getting Log4net to work Can anybody spot what I am doing wrong? I'm probably doing something stupid, but I've been banging my head against this for a few days and am getting no further: I have a solution comprising two projects, a client app and a logger project. The logger project encapsulates calls to log4net. It has a line in its AssemblyInfo file [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] and static loggers and methods to call various loggers, eg private static readonly ILog bllDebugLog = LogManager.GetLogger("Matrix.Trace"); and so on. a Typical logging method in the logger code is public static void Trace(string message) { using (NDC.Push("TRACE")) { bllDebugLog.Debug(message); } } In the same solution I have an application which references the above assembly. The application makes calls to the static log methods, eg logger.Trace("a message"); and the log4net.config file is in the executable directory of the application (...\bin\debug and ...\bin\release). It all seems straight out of the book, but try as I might I cannot get log4net to log anything! The bare bones of the log4net.config file is: <?xml version="1.0" encoding="utf-8" ?> <configuration> <log4net> <appender name="RollingFileAppenderROOT" type="log4net.Appender.RollingFileAppender"> <file value="c:\logs\MatrixROOT.log" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%m%newline" /> </layout> <appendToFile value="true" /> <maximumFileSize value="100KB" /> <maxSizeRollBackups value="2" /> </appender> <appender name="RollingFileAppenderTRACE" type="log4net.Appender.RollingFileAppender"> <file value="c:\logs\MatrixTRACE.log" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%m%newline" /> </layout> <appendToFile value="true" /> <maximumFileSize value="100KB" /> <maxSizeRollBackups value="2" /> </appender> <root> <appender-ref ref="RollingFileAppenderROOT" /> </root> <logger name="Matrix.Trace"> <!--this is for routine debug logging to a file--> <level value="DEBUG" /> <appender-ref ref="RollingFileAppenderTRACE" /> </logger> </log4net> </configuration> TIA Neil