NH Logging Abstraction

8 views
Skip to first unread message

Brian Chavez

unread,
Oct 21, 2008, 6:23:42 PM10/21/08
to nhibernate-...@googlegroups.com

Hi,

 

I just wanted to float the idea of using a Common.Logging abstraction for NHibernate.

 

http://netcommon.sourceforge.net/index.html

 

Personally, I've been frustrated by NHibernate's dependency on log4net for a long time.  I use NLog for all my logging in all my apps, and it would be nice to consolidate NHibernate's logging onto the same logging infrastructure that my application uses.

 

I don't see any benefit of having two separate logging infrastructures and I think NH developers should have the freedom to choose their logging implementation.

 

Benefits are:

1) I can configure the logging in NHibernate to use log4net or NLog.

2) We get more control over logging.

3) Impact of switching to Common.Logging should be minimal.

 

I just wanted to float the idea with all of you to gauge whether or not you like the idea.  If it's worth exploring, I'll be willing to work on a patch with Common.Logging.

 

Thanks,

Brian

 

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

Fabio Maulo

unread,
Oct 21, 2008, 6:38:54 PM10/21/08
to nhibernate-...@googlegroups.com
Interesting even if
"The library is based on work done by the developers of IBatis.NET and it's usage is inspired by log4net."
Long work to do in NH and we having some other priority.
Please create a JIRA about it.
Thanks.

2008/10/21 Brian Chavez <bch...@bitarmory.com>



--
Fabio Maulo

Brian Chavez

unread,
Oct 21, 2008, 7:58:50 PM10/21/08
to nhibernate-...@googlegroups.com

Hi Fabio,

 

I totally understand you guys have other issues that have higher priority.

 

If I submit a patch for this, what "working base" should I make the patch from?  SVN /trunk or off the latest offical src.zip release?

 

Thanks,

Brian

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

josh robb

unread,
Oct 23, 2008, 7:40:47 AM10/23/08
to nhibernate-...@googlegroups.com
From the trunk.

To be honest - I'd have thought that writing a NLogAppender for
log4net might solve your problem a _lot_ easier. (Depending on what
exactly the problem is).

j.

Berke

unread,
Oct 24, 2008, 11:31:47 AM10/24/08
to nhibernate-development
I like the idea of making the logging pluggable, its sort of like the
idea of having a common standard interface for IoC containers so that
developers can bring their own IoC to the table and not be forced to
utilize multiple containers.
> > 2008/10/21 Brian Chavez <bcha...@bitarmory.com>
> > Fabio Maulo- Hide quoted text -
>
> - Show quoted text -

Fabio Maulo

unread,
Oct 24, 2008, 11:38:40 AM10/24/08
to nhibernate-...@googlegroups.com
2008/10/24 Berke <joshua...@gmail.com>


I like the idea of making the logging pluggable, its sort of like the
idea of having a common standard interface for IoC containers so that
developers can bring their own IoC to the table and not be forced to
utilize multiple containers.

--
Fabio Maulo

Brian Chavez

unread,
Oct 26, 2008, 1:32:04 AM10/26/08
to nhibernate-...@googlegroups.com
I checked out the /trunk and quickly surveyed how difficult the move to
Common.Logging would be, and it doesn't look that difficult...

LogManager and ILog are (strikingly) identical between log4net and
Common.Logging, with one small exception.

log4net.ILog has format helper methods like DebugFormat(...);

Common.Logging.ILog does not define format helper methods. The interface
only defines:

public interface ILog
{
// Methods
void Debug(object message);
void Debug(object message, Exception exception);
void Error(object message);
void Error(object message, Exception exception);
void Fatal(object message);
void Fatal(object message, Exception exception);
void Info(object message);
void Info(object message, Exception exception);
void Trace(object message);
void Trace(object message, Exception exception);
void Warn(object message);
void Warn(object message, Exception exception);

// Properties
bool IsDebugEnabled { get; }
bool IsErrorEnabled { get; }
bool IsFatalEnabled { get; }
bool IsInfoEnabled { get; }
bool IsTraceEnabled { get; }
bool IsWarnEnabled { get; }
}

The format helpers are used throughout NH. Any thoughts on how to (or not)
proceed?

----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

Fabio Maulo

unread,
Oct 26, 2008, 6:59:38 AM10/26/08
to nhibernate-...@googlegroups.com
Wait a minute...
If we will remove the dependency from log4net is because we don't want any other dependency.
I mean.... if we will remove dependency from log4net is not to have a dependency to Common.Logging.
Clear, no?

2008/10/26 Brian Chavez <bch...@bitarmory.com>



--
Fabio Maulo

josh robb

unread,
Oct 26, 2008, 7:36:57 AM10/26/08
to nhibernate-...@googlegroups.com
On Sun, Oct 26, 2008 at 9:59 PM, Fabio Maulo <fabio...@gmail.com> wrote:
> Wait a minute...
> If we will remove the dependency from log4net is because we don't want any
> other dependency.
> I mean.... if we will remove dependency from log4net is not to have a
> dependency to Common.Logging.
> Clear, no?

Exactly - there are two separate ideas here:

1. NH-Devs - Removing static third party dependancies.
2. Brian - Allowing using other logging frameworks.

Replacing a hard dependancy on log4net with one on Common.Logging
isn't really a huge win for 1 - but it might be for 2.

j.

Brian Chavez

unread,
Oct 26, 2008, 3:21:47 PM10/26/08
to nhibernate-...@googlegroups.com
What I've been talking about is exchanging the dependency on log4net with
Common.Logging. Why? Because this gives the freedom for NHUsers to
choose/plug their logging framework into NHibernate whether it be NLog,
log4net, or EntLib Logging.

If NHUsers don't want (or use) any of the logging frameworks mentioned, they
can implement their own ILoggerFractoryAdapter that will work just the same.
This is the fundamental purpose of Common.Logging.

http://netcommon.sourceforge.net/doc-latest/reference/html/logging.html

I guess if you want to break the dependency on log4net AND keep
Common.Logging out all together, then NH needs its own Logging that is
pluggable.
Possibly, a NHibernate.Logging namespace with some interfaces that NHUsers
can implement, and a LoggerFactory type that can be defined in an NH Config
File. However, I think this approach is basically reinventing the wheel
because Common.Logging already has this functionality.

-Brian


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com


-----Original Message-----
From: nhibernate-...@googlegroups.com
[mailto:nhibernate-...@googlegroups.com] On Behalf Of josh robb
Sent: Sunday, October 26, 2008 4:37 AM
To: nhibernate-...@googlegroups.com
Subject: [nhibernate-development] Re: NH Logging Abstraction

Fabio Maulo

unread,
Oct 26, 2008, 5:23:57 PM10/26/08
to nhibernate-...@googlegroups.com
When, and if, we will don't use log4net will be because NH don't have hard dependency in nothing more than .NET FW.

BTW I don't understand which is the problem, or where NLog is better than log4net, or why a NH-user may have so many problems because NH are using log4net...

I can understand that the purpose of Common.Logging if abstraction from logging system but, really, how some other dependency make NH purposes better...
Perhaps Common.Logging it is interesting from the point of view of one application but for a FW as NH...


2008/10/26 Brian Chavez <bch...@bitarmory.com>



--
Fabio Maulo

Steve Wagner

unread,
Oct 28, 2008, 5:35:06 AM10/28/08
to nhibernate-...@googlegroups.com
Fabio Maulo schrieb:

> BTW I don't understand which is the problem, or where NLog is better than
> log4net, or why a NH-user may have so many problems because NH are using
> log4net...

A lot people say that the only reason they using log4net is because a
lot of library's use log4net too. But they find the configuration of
NLog much better then log4net.

So a switch to Common.Logging or i little custom wrapper is a good
suggestion i think.

Steve

Fabio Maulo

unread,
Oct 28, 2008, 8:41:44 AM10/28/08
to nhibernate-...@googlegroups.com
Yes, Steve.
You know that we love DependencyInjection and less couple with other FW.

At the end... do somebody had created a JIRA ?

2008/10/28 Steve Wagner <li...@lanwin.de>



--
Fabio Maulo

Brian Chavez

unread,
Oct 28, 2008, 3:38:35 PM10/28/08
to nhibernate-...@googlegroups.com

 

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

From: nhibernate-...@googlegroups.com [mailto:nhibernate-...@googlegroups.com] On Behalf Of Fabio Maulo
Sent: Tuesday, October 28, 2008 5:42 AM
To: nhibernate-...@googlegroups.com
Subject: [nhibernate-development] Re: NH Logging Abstraction

 

Yes, Steve.

Tuna Toksöz

unread,
Oct 28, 2008, 3:54:34 PM10/28/08
to nhibernate-...@googlegroups.com
I don't know how much it is of importance but that project has its latest release on 10/10/2007.

What do you guys think, is it dead or active?
--
Tuna Toksöz

Typos included to enhance the readers attention!

Brian Chavez

unread,
Oct 28, 2008, 4:47:00 PM10/28/08
to nhibernate-...@googlegroups.com

Well, the last release for log4net (1.2.10) was sometime in 2006 according to:

 

http://svn.apache.org/viewvc?view=rev&sortdir=down&revision=395324

 

http://jira.nhibernate.org/browse/NH-696

 

The last release for NLog was also in 2006.

 

I suppose, the release cycle for logging frameworks don't change much.

 

I'll shoot an email over to their mailing list to see if their still active.

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

Tuna Toksöz

unread,
Oct 28, 2008, 4:58:31 PM10/28/08
to nhibernate-...@googlegroups.com
Well, we'll anyway need to abstract it, we'd prefer dependency only on .net FW.

Steve Wagner

unread,
Oct 29, 2008, 7:47:26 AM10/29/08
to nhibernate-...@googlegroups.com
So maybe it would the best if the dependency of log4net gets removed and
would be replaced with a simple and similar interface which per default
redirects all logging to System.Diagnostics. So a logging without an
additional libs is possible.

And then there could be a contrib project which provides adapters for
log4net and NLog. And all are happy :-)

Tuna Toksöz schrieb:


> Well, we'll anyway need to abstract it, we'd prefer dependency only on .net
> FW.
>
>
> On Tue, Oct 28, 2008 at 10:47 PM, Brian Chavez <bch...@bitarmory.com>wrote:
>
>> Well, the last release for log4net (1.2.10) was sometime in 2006
>> according to:
>>
>>
>>
>> http://svn.apache.org/viewvc?view=rev&sortdir=down&revision=395324
>>
>>
>>
>> http://jira.nhibernate.org/browse/NH-696
>>
>>
>>
>> The last release for NLog was also in 2006.
>>
>>
>>
>> I suppose, the release cycle for logging frameworks don't change much.
>>
>>
>>
>> I'll shoot an email over to their mailing list to see if their still
>> active.
>>
>>
>>
>>
>> ----------------------------------------------
>> Brian Chavez
>> Bit Armory, Inc.
>> http://www.bitarmory.com
>>
>>
>>

>> *From:* nhibernate-...@googlegroups.com [mailto:
>> nhibernate-...@googlegroups.com] *On Behalf Of *Tuna Toksöz
>> *Sent:* Tuesday, October 28, 2008 12:55 PM
>>
>> *To:* nhibernate-...@googlegroups.com
>> *Subject:* [nhibernate-development] Re: NH Logging Abstraction


>>
>>
>>
>> I don't know how much it is of importance but that project has its latest
>> release on 10/10/2007.
>>
>> What do you guys think, is it dead or active?
>>
>> On Tue, Oct 28, 2008 at 9:38 PM, Brian Chavez <bch...@bitarmory.com>
>> wrote:
>>
>> JIRA created:
>>
>>
>>
>> http://jira.nhibernate.org/browse/NH-1554
>>
>>
>>
>>
>>
>>
>> ----------------------------------------------
>> Brian Chavez
>> Bit Armory, Inc.
>> http://www.bitarmory.com
>>
>>
>>

>> *From:* nhibernate-...@googlegroups.com [mailto:
>> nhibernate-...@googlegroups.com] *On Behalf Of *Fabio Maulo
>> *Sent:* Tuesday, October 28, 2008 5:42 AM
>>
>>
>> *To:* nhibernate-...@googlegroups.com
>> *Subject:* [nhibernate-development] Re: NH Logging Abstraction

Fabio Maulo

unread,
Oct 29, 2008, 7:54:00 AM10/29/08
to nhibernate-...@googlegroups.com
2008/10/29 Steve Wagner <li...@lanwin.de>


So maybe it would the best if the dependency of log4net gets removed and
would be replaced with a simple and similar interface which per default
redirects all logging to System.Diagnostics. So a logging without an
additional libs is possible.

And then there could be a contrib project which provides adapters for
log4net and NLog. And all are happy :-)

Yes.
But I hope you can understand that we would like implements TransactionContext (and related stuff), EntityMode.Xml, property laziness, AST HQL parser, Linq2NH and some bug fix before concentrate our effort to change the log system.

BTW if some committer would work on logging abstraction there is no problem (NH have 22 committers).
--
Fabio Maulo

Tuna Toksöz

unread,
Oct 29, 2008, 8:04:44 AM10/29/08
to nhibernate-...@googlegroups.com
Or anyone not in the committer list can send patches too, but this would be huge!

Brian Chavez

unread,
Oct 29, 2008, 2:34:15 PM10/29/08
to nhibernate-...@googlegroups.com
That's is a good idea Fabio. I think it would be great, as long as
NHibernate log/trace output does not go to the "output window" in visual
studio when debugging. Otherwise it would be chaos in that window :P

BTW Tuna, for what it's worth, I got a response from Common.Logging dev
list:

Hi,

Yes it is still active, I founded the project and do most of the
development, Bruno Baia is another developer on the project. I'd be quite
happy to use this opportunity to make a new release of Commons.Logging that
addresses the remaining open issues. Are there other feature requests that
would be specific to NHibernate adopting Common.Logging? As for the 'when',
starting in the 2nd week of November I'll have time to address these issues,
I don't think they will take long to fix.

Cheers,
Mark


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

Tuna Toksöz

unread,
Oct 29, 2008, 2:37:32 PM10/29/08
to nhibernate-...@googlegroups.com
Well, mine was just thinking out loud :) Thanks for your interest in NH.
Will you consider creating patches

Brian Chavez

unread,
Oct 29, 2008, 3:02:40 PM10/29/08
to nhibernate-...@googlegroups.com

Yes, I'll be glad to work on a patch for System.Diagnostics Logging.

 

I just need some time to read up on System.Diag, think about correct implementation, and optimize a painless way to go about making the change.  If I have any issues, I'll keep the list posted. 

 

I have a commercial project due in a few weeks and will put some effort into logging soon after.

 

-Brian

 


----------------------------------------------
Brian Chavez
Bit Armory, Inc.
http://www.bitarmory.com

 

Tuna Toksöz

unread,
Oct 29, 2008, 5:26:14 PM10/29/08
to nhibernate-...@googlegroups.com
Looking forward to it.

alwin

unread,
Nov 2, 2008, 6:09:29 AM11/2/08
to nhibernate-development
Did you have had a look at Castle Project logging? It has support for
System.Diagnostics, log4net and NLog. From this thread i understand
that the NH team doesn't want more deps, not no Castle.Core either.
But perhaps you can look at the code and use parts of it to put
directly into NH, for example the ILogger/ILoggerFactory abstractions.
Just to let you know.

http://svn.castleproject.org:8080/svn/castle/trunk/Core/Castle.Core/Logging/

On 29 okt, 20:02, "Brian Chavez" <bcha...@bitarmory.com> wrote:
> Yes, I'll be glad to work on a patch for System.Diagnostics Logging.
>
> I just need some time to read up on System.Diag, think about correct
> implementation, and optimize a painless way to go about making the change.
> If I have any issues, I'll keep the list posted.  
>
> I have a commercial project due in a few weeks and will put some effort into
> logging soon after.
>
> -Brian
>
> ----------------------------------------------
> Brian Chavez
> Bit Armory, Inc.http://www.bitarmory.com
>
> From: nhibernate-...@googlegroups.com
> [mailto:nhibernate-...@googlegroups.com] On Behalf Of Tuna Toksöz
> Sent: Wednesday, October 29, 2008 11:38 AM
> To: nhibernate-...@googlegroups.com
> Subject: [nhibernate-development] Re: NH Logging Abstraction
>
> Well, mine was just thinking out loud :) Thanks for your interest in NH.
> Will you consider creating patches
>
> On Wed, Oct 29, 2008 at 8:34 PM, Brian Chavez <bcha...@bitarmory.com> wrote:
>
> That's is a good idea Fabio.  I think it would be great, as long as
> NHibernate log/trace output does not go to the "output window" in visual
> studio when debugging. Otherwise it would be chaos in that window :P
>
> BTW Tuna, for what it's worth, I got a response from Common.Logging dev
> list:
>
> Hi,
>
> Yes it is still active, I founded the project and do most of the
> development, Bruno Baia is another developer on the project.  I'd be quite
> happy to use this opportunity to make a new release of Commons.Logging that
> addresses the remaining open issues.  Are there other feature requests that
> would be specific to NHibernate adopting Common.Logging?  As for the 'when',
> starting in the 2nd week of November I'll have time to address these issues,
> I don't think they will take long to fix.
>
> Cheers,
> Mark
>
> ----------------------------------------------
> Brian Chavez
> Bit Armory, Inc.http://www.bitarmory.com
>
> -----Original Message-----
> From: nhibernate-...@googlegroups.com
>
> [mailto:nhibernate-...@googlegroups.com] On Behalf Of Steve Wagner
> Sent: Wednesday, October 29, 2008 4:47 AM
> To: nhibernate-...@googlegroups.com
> Subject: [nhibernate-development] Re: NH Logging Abstraction
>
> So maybe it would the best if the dependency of log4net gets removed and
> would be replaced with a simple and similar interface which per default
> redirects all logging to System.Diagnostics. So a logging without an
> additional libs is possible.
>
> And then there could be a contrib project which provides adapters for
> log4net and NLog. And all are happy :-)
>
> Tuna Toksöz schrieb:
> > Well, we'll anyway need to abstract it, we'd prefer dependency only on
> .net
> > FW.
>
> > On Tue, Oct 28, 2008 at 10:47 PM, Brian Chavez
> <bcha...@bitarmory.com>wrote:
>
> >>  Well, the last release for log4net (1.2.10) was sometime in 2006
> >> according to:
>
> >>http://svn.apache.org/viewvc?view=rev
> <http://svn.apache.org/viewvc?view=rev&sortdir=down&revision=395324>
> &sortdir=down&revision=395324
>
> >>http://jira.nhibernate.org/browse/NH-696
>
> >> The last release for NLog was also in 2006.
>
> >> I suppose, the release cycle for logging frameworks don't change much.
>
> >> I'll shoot an email over to their mailing list to see if their still
> >> active.
>
> >> ----------------------------------------------
> >> Brian Chavez
> >> Bit Armory, Inc.
> >>http://www.bitarmory.com
>
> >> *From:* nhibernate-...@googlegroups.com [mailto:
> >> nhibernate-...@googlegroups.com] *On Behalf Of *Tuna Toksöz
> >> *Sent:* Tuesday, October 28, 2008 12:55 PM
>
> >> *To:* nhibernate-...@googlegroups.com
> >> *Subject:* [nhibernate-development] Re: NH Logging Abstraction
>
> >> I don't know how much it is of importance but that project has its latest
> >> release on 10/10/2007.
>
> >> What do you guys think, is it dead or active?
>
> >> On Tue, Oct 28, 2008 at 9:38 PM, Brian Chavez <bcha...@bitarmory.com>
Reply all
Reply to author
Forward
0 new messages