--- Matthew Brown <[EMAIL PROTECTED]> wrote:

> Why are you not using a config file? That would be the (far) easiest way...

#1 - many sites/services/apps all of which have to have the config file changed
when a version update happens. Really annoying
#2 - by putting in source, and by programatically determining the environment,
ie. local, dev, qa, live, the number of configurations goes down to one simple
source file appropriate for our source control system
#3 - don't repeat yourself!
#4 - I prefer writing in c# to xml

> 
> On 11/25/05, Philip Nelson <[EMAIL PROTECTED]> wrote:
> >
> > I had added a configuration that built my loggers in code only and all was
> > well
> > (no xml!). Later though, I found out that NHibernate is doing something
> > bad,
> > logging exceptions with log.Error. These exceptions are handled by the
> > caller,
> > so I really don't want those log calls made at all. No problem, I thought
> > I'd
> > create a repository for the NHibernate assembly, setup the appender I
> > want, and
> > this would get used instead of my default logger that sends emails on
> > error.
> >
> > ILoggerRepository logger = Reset(); //the normal logger
> >
> > string pattern = "%d %-5p %c %x - %m%n";
> > string filename = Path.Combine(_logPath, LogFileName);
> > string debugFilename = Path.Combine(_logPath + "debug/", LogFileName);
> >
> > //setup nhibernate logger separately so it will not email errors
> > Type nType = AppContext.ActiveSession.GetType(); //gets the NHibernate
> > ISession
> > Assembly nhib = nType.Assembly;
> > ILoggerRepository nrep = null;
> > ILogger l = LoggerManager.GetLogger(nhib, nType);
> > nrep = l.Repository;
> > nrep.ResetConfiguration();
> > ForwardingAppender dbgAppender = new ForwardingAppender();
> > dbgAppender.AddAppender(setupDebugAppender(pattern, Path.Combine(_logPath
> > +
> > "debug/NHib", LogFileName)));
> > log4net.Config.BasicConfigurator.Configure(nrep, dbgAppender);
> >
> > My assumption was that the normal logger repository, "logger" would now
> > not be
> > used because NHibernate gets its logger with
> > LogManager.GetLogger(typeof(this)).
> >
> > The new logger logs correctly, but the original logger also logs, so my
> > goal of
> > getting rid of the emails wasn't met.
> >
> > Any ideas about how to cheat NHibernate of it's logging?
> >
> > Philip - http://www.xcskiwinn.org/community/blogs/panmanphil/default.aspx
> > "Now that was a bad vowel movement" - Barbara
> >
>


Philip - http://www.xcskiwinn.org/community/blogs/panmanphil/default.aspx
"Now that was a bad vowel movement" - Barbara

Reply via email to