views:

56

answers:

2

Are you ever succeed input NHibernate logging using CodeCampServer architecture?

I read this and I did everything that I can. Maybe there is know problem in this architecture.

I using Infrastructure.NHibernate.DataAccess.Bases.Logger.EnsureInitialized(); to initialize log4net. here the code:

public class DependencyRegistrar
{
    private static bool _dependenciesRegistered;

    private static void RegisterDependencies()
    {
        ObjectFactory.Initialize(x => x.Scan(y =>
                                                {
                                                    y.AssemblyContainingType<DependencyRegistry>();
                                                    y.AssemblyContainingType<NaakRegistry>();
                                                    y.LookForRegistries();
                                                    y.AddAllTypesOf<IRequiresConfigurationOnStartup>();
                                                }));
        new InitiailizeDefaultFactories().Configure();
    }

    private static readonly object sync = new object();

    internal void ConfigureOnStartup()
    {
        Infrastructure.NHibernate.DataAccess.Bases.Logger.EnsureInitialized();

        RegisterDependencies();
        var dependenciesToInitialized = ObjectFactory.GetAllInstances<IRequiresConfigurationOnStartup>();
        foreach (var dependency in dependenciesToInitialized)
        {
            dependency.Configure();
        }
    }
    public static T Resolve<T>()
    {
        return ObjectFactory.GetInstance<T>();
    }

    public static object Resolve(Type modelType)
    {
        return ObjectFactory.GetInstance(modelType);
    }

    public static bool Registered(Type type)
    {
        EnsureDependenciesRegistered();
        return ObjectFactory.GetInstance(type) != null;
    }

    public static void EnsureDependenciesRegistered()
    {
        if (!_dependenciesRegistered)
        {
            lock (sync)
            {
                if (!_dependenciesRegistered)
                {
                    RegisterDependencies();
                    _dependenciesRegistered = true;

                }
            }
        }
    }
} 

And I see the logging files, I can't delete them when the app run, so I know they are generated. in addition, when I log for test, the log are input. For example, this code do input log.

    Bases.Logger.Debug(this, "Debug test!")

So, do CodeCampServer have a architecture problem with log4net?

A: 

The post looks correct to me. Are you sure you added the necessary assembly level attribute?

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

If this won't work maybe you should try:

log4net.Config.XmlConfigurator.Configure();

for example in your Application_Start of Global.asax. If this won't work please post your example code.

zoidbeck
I do something equivalent, look for the code above.
Mendy
The Logwrapper you are using ignores the configuration within your App.config. So can you post the Log4Net.config file that is used by this logger?http://code.google.com/p/codecampserver/source/browse/trunk/src/Infrastructure/DataAccess/Bases/Logger.cs?r=1033
zoidbeck
The Default Log4net.config that is used sets NHibernate logging to FATAL. See here: http://code.google.com/p/codecampserver/source/browse/trunk/src/Log4Net.config?r=1033
zoidbeck
The priority is in Debug mode. The problem is not in the Log4Net.config file as the file was generated.
Mendy
A: 

Accidentally found solution by replacing the reference forlog4net.dll to the on that come with NHibernate bins, instead the own log4net.

Wired, but I have logs... :)

Mendy