Monday, May 21, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: configuration problems, not logging
Prev Next
You are not authorized to post a reply.

Author Messages
suedeuno

11/25/2008 9:05 PM  


What's missing here? Using profiler, the database never receives the call.

web.config:
    <log4net>
        <appender name="ADONetAppender"
type="log4net.Appender.ADONetAppender">
            <bufferSize value="100" />
            <connectionType value="System.Data.SqlClient.SqlConnection,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
            <connectionString value="data source=(local)\SQLEXPRESS;initial
catalog=MyTestDB;integrated security=false;persist security info=True;User
ID=user;Password=pass" />
            <commandText value="INSERT INTO Log
([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date,
@thread, @log_level, @logger, @message, @exception)" />
........ etc
        <root>
            <level value="ERROR" />
            <appender-ref ref="ADONetAppender" />
        </root>
        <logger name="LogUtility">
            <level value="ALL" />
        </logger>
</log4net>

global.asax application_start
log4net.Config.XmlConfigurator.Configure();

log wrapper:
    public class LogUtility : ILogUtility
    {
        private ILog log { get; set; }

        public LogUtility()
        {
            log = LogManager.GetLogger("LogUtility"); //
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        }

        #region ILogUtility Members

        public void LogException(string message)
        {
            log.Error(message);
        }

        public void LogException(string message, Exception exception)
        {
            log.Error(message, exception);
        }

default.aspx log call:
 LogUtility.LogException("some error", new Exception());


--
View this message in context: http://www.nabble.com/configuration-problems%2C-not-logging-tp20688643p20688643.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Ron Grabowski

11/25/2008 10:47 PM  

I don't know if it matters or not but the Type is AdoNetAppender not ADONetAppender. Do you see a TypeLoadException when you turn on log4net's internal debugging?

suedeuno

11/25/2008 10:56 PM  

I have internal debugging on and no errors are given. Everything executes
without error.
I stepped through the execution, and looked at the instance of log noticing
that all of the IsErrorEnabled, etc were false. I even added a simple file
appender and appropriate access to the file and still nothing.

suedeuno

11/26/2008 6:44 PM  

I created a unit test and got some debug info back finally but I'm unclear
why it's happening. I'm calling Configure in my utility class ->
public LogUtility()
        {
            log4net.Config.XmlConfigurator.Configure();
            log =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        }



LogUtilityTests.LoggerIsSuccessful : Passedlog4net: log4net assembly
[log4net, Version=1.2.10.0, Culture=neutral,

PublicKeyToken=1b44e1d426115821]. Loaded from [Global Assembly Cache]. (.NET
Runtime ΐ.0.50727.3053] on Microsoft Windows NT 5.1.2600 Service

Pack 2)
log4net: log4net assembly [log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=1b44e1d426115821]. Loaded from [Global Assembly Cache].

(.NET Runtime ΐ.0.50727.3053] on Microsoft Windows NT 5.1.2600 Service Pack
2)
log4net: DefaultRepositorySelector: defaultRepositoryType
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: defaultRepositoryType
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Creating repository for assembly
[Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]
log4net: DefaultRepositorySelector: Creating repository for assembly
[Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null] Loaded From [C:\Documents and

Settings\user\Local
Settings\Temp\tpo4otwu.afk\Common.Test\assembly\dl3\276e0687\2c87db19_ed4fc901\Common.DLL]
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null] Loaded From [C:\Documents and

Settings\user\Local
Settings\Temp\tpo4otwu.afk\Common.Test\assembly\dl3\276e0687\2c87db19_ed4fc901\Common.DLL]
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null] does not have a RepositoryAttribute

specified.
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null] does not have a RepositoryAttribute

specified.
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null] using repository

[log4net-default-repository] and repository type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Assembly [Common, Version=1.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: DefaultRepositorySelector: Creating repository
[log4net-default-repository] using type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using .config file section
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using .config file section
log4net: XmlConfigurator: Application config file is [C:\Documents and
Settings\user\My Documents\Visual Studio

2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config]
log4net: XmlConfigurator: Application config file is [C:\Documents and
Settings\user\My Documents\Visual Studio

2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config]
log4net:ERROR XmlConfigurator: Failed to parse config file. Is the
<configSections> specified as: <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net,
Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
log4net:ERROR XmlConfigurator: Failed to parse config file. Is the
<configSections> specified as: <section name="log4net"

type="log4net.Config.Log4NetConfigurationSectionHandler,log4net,
Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
System.Configuration.ConfigurationErrorsException: An error occurred
creating the configuration section handler for log4net: Could not load file

or assembly 'log4net' or one of its dependencies. The system cannot find the
file specified. (C:\Documents and Settings\user\My Documents\Visual

Studio 2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config
line 5) ---> System.IO.FileNotFoundException: Could not load file or

assembly 'log4net' or one of its dependencies. The system cannot find the
file specified.
File name: 'log4net'
   at
System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost
host, String typeString, Boolean throwOnError)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord
configRecord, FactoryRecord

factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord

configRecord, FactoryRecord factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory..ctor(RuntimeConfigurationRecord
configRecord, FactoryRecord

factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord
factoryRecord)
   at
System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String
configKey, Boolean& isRootDeclaredHere)

=== Pre-bind state information ===
LOG: User = domain\user
LOG: DisplayName = log4net
 (Partial)
LOG: Appbase = file:///C:/Documents and Settings/user/My Documents/Visual
Studio 2008/Projects/project1/Common.Test/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\user\My
Documents\Visual Studio

2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config
LOG: Using machine configuration file from
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net.EXE.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net/log4net.EXE.

   --- End of inner exception stack trace ---
   at
System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String
configKey, Boolean& isRootDeclaredHere)
   at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean

getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey, Boolean getLkg, Boolean checkPermission)
   at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey)
   at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String
sectionName)
   at log4net.Config.XmlConfigurator.Configure(ILoggerRepository repository)
System.Configuration.ConfigurationErrorsException: An error occurred
creating the configuration section handler for log4net: Could not load file

or assembly 'log4net' or one of its dependencies. The system cannot find the
file specified. (C:\Documents and Settings\user\My Documents\Visual

Studio 2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config
line 5) ---> System.IO.FileNotFoundException: Could not load file or

assembly 'log4net' or one of its dependencies. The system cannot find the
file specified.
File name: 'log4net'
   at
System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost
host, String typeString, Boolean throwOnError)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord
configRecord, FactoryRecord

factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord

configRecord, FactoryRecord factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory..ctor(RuntimeConfigurationRecord
configRecord, FactoryRecord

factoryRecord)
   at
System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord
factoryRecord)
   at
System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String
configKey, Boolean& isRootDeclaredHere)

=== Pre-bind state information ===
LOG: User = domain\user
LOG: DisplayName = log4net
 (Partial)
LOG: Appbase = file:///C:/Documents and Settings/user/My Documents/Visual
Studio 2008/Projects/project1/Common.Test/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\user\My
Documents\Visual Studio

2008\Projects\project1\Common.Test\bin\Debug\Common.Test.dll.config
LOG: Using machine configuration file from
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net.EXE.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/user/My Documents/Visual Studio

2008/Projects/project1/Common.Test/bin/Debug/log4net/log4net.EXE.

   --- End of inner exception stack trace ---
   at
System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String
configKey, Boolean& isRootDeclaredHere)
   at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean

getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey, Boolean getLkg, Boolean checkPermission)
   at System.Configuration.BaseConfigurationRecord.GetSection(String
configKey)
   at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String
sectionName)
   at log4net.Config.XmlConfigurator.Configure(ILoggerRepository repository)

suedeuno

11/26/2008 10:54 PM  

Ok, I added [assembly: XmlConfigurator()] to the AssemblyInfo files and the
unit tests log the messages successfully however I still am unable to log
from the web project. Ideas anyone?

Ron Grabowski

11/26/2008 11:45 PM  

What happens when you make the buffer size 1?

suedeuno

11/26/2008 11:50 PM  

I got it to work. I removed a named logger in the config file and that seemed
to make it work. Still not sure why I had to use attributes in the
assemblyinfo files though, I was calling
log4net.Config.XmlConfigurator.Configure(); in my logger class.

Radovan Raszka

11/27/2008 10:17 AM  

You probably missing these lines in your web.config / app.config
<configSections>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

See http://logging.apache.org/log4net/release/manual/configuration.html, .config Files paragraph

Radovan

suedeuno

12/01/2008 6:05 PM  

Actually that section is present in the web.config. Strangely if I remove the
attribute from assembly.info no logging occurs, but if I replace the
attribute back to the assembly.info then logging works. Is there an issue
with log4net and .Net 3.5 framework?

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > configuration problems, not logging



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement