logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross Hinkley <rosshink...@gmail.com>
Subject Re: Log in more than 1 log destination for different assemblies.
Date Wed, 02 Sep 2009 13:32:36 GMT
It's possible, sure.  If you're talking about having separate executables
log to the same logfile, in their application configurations, use the same
filename and path.

One thing I can't recall off the top of my head, though, is how log4net
deals with file locks.  Someone out there, please correct me if I'm wrong,
but if you log two messages to the same file at nearly the same time, won't
they be buffered?  (If memory serves, you can fiddle with the buffer size
using the "bufferSize" element.)  I believe if you're using a FileAppender
you can specify what kind of locking you want to do, like:

<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

That should prevent write lock exceptions.

Alternatively, I would humbly recommend you take a look at logging to a
database instead.  It sounds like you want a central log, and you would gain
a little more flexibility that way.


On Wed, Sep 2, 2009 at 3:28 AM, mattyboy <mattm@spdprintsolutions.com>wrote:

> Hi Christian,
> I'm actually looking to achieve the opposite, I want to know if it's
> possible to get several assemblies to log to the SAME log file.  Have you
> managed to achieve this?  If so, do you have any example code/configs etc.?
> Many Thanks
> cristianmad wrote:
> >
> > Hi,
> >
> > I am new to log4net and just starting reading some documentation about
> it.
> > We need to see if it would be a suitable logging solution for our
> > applications.
> > Our product (like most of them) uses a number of assemblies. I was
> > wondering if it would be possible for each assembly to log in its own log
> > file (or any other destination) even if they are loaded in the same
> > application domain.
> > For example consider we have the following assemblies: A.dll and B.dll.
> Is
> > it possible for the two assemblies to log in their own log files even if
> > they are loaded in the same application domain?
> > If yes, could you please give me a very simple example?
> >
> >
> > Thank you,
> > Cristian
> >
> --
> View this message in context:
> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message