473,511 Members | 10,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using log4net to write to one log file from multiple programs.

UJ
Has anybody done anything with using log4net where you have multiple
programs on a single machine writing to the same log file?

TIA - J.
Sep 8 '06 #1
3 15625

Just config so that each app does not lock the file. That affects
performance because the app has to open the file, flush the message,
and close the file immediatly.

Add following element into FileAppender/RollingFileAppender elements of
each XML config file:
<param name="LockingModel"
type="log4net.Appender.FileAppender+MinimalLock" />

UJ wrote:
Has anybody done anything with using log4net where you have multiple
programs on a single machine writing to the same log file?

TIA - J.
Sep 9 '06 #2
Truong Hong Thi <th*****@gmail.comwrote:
Just config so that each app does not lock the file. That affects
performance because the app has to open the file, flush the message,
and close the file immediatly.

Add following element into FileAppender/RollingFileAppender elements of
each XML config file:
<param name="LockingModel"
type="log4net.Appender.FileAppender+MinimalLock" />
That's the correct config, but your first sentence is wrong - it *does*
lock the file. The point of MinimalLock is that it locks it, but does
so for as short a time as possible. Without *any* locking, two
different programs could corrupt each others' lock.

From the docs for MinimalLock:

<quote>
Acquires the file lock for each write
</quote>

That's quite different from not locking the file at all!

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 9 '06 #3

Thanks Jon. I understood that, just did not express it right.
I used to work on a project where a web app and a web service logged to
the same file.
It *greatly* reduced performance when we turned on debug log since we
logged many debug messages.

Jon wrote:
Truong Hong Thi <th*****@gmail.comwrote:
Just config so that each app does not lock the file. That affects
performance because the app has to open the file, flush the message,
and close the file immediatly.

Add following element into FileAppender/RollingFileAppender elements of
each XML config file:
<param name="LockingModel"
type="log4net.Appender.FileAppender+MinimalLock" />

That's the correct config, but your first sentence is wrong - it *does*
lock the file. The point of MinimalLock is that it locks it, but does
so for as short a time as possible. Without *any* locking, two
different programs could corrupt each others' lock.

From the docs for MinimalLock:

<quote>
Acquires the file lock for each write
</quote>

That's quite different from not locking the file at all!

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
9586
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
2
11932
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
3
8831
by: Jer425 | last post by:
Hello all, I'm trying to post to another page from asp.net and direct the user there. I've looked through the group and found a lot of information. The following code may work well for what I'm...
1
2253
by: Petterson Mikael | last post by:
Hi, I am using xalan. In my stylesheet I have the following snippet to write to std out when a specific error occurs. <xsl:template name="class_error"> <xsl:param name="class"/> <xsl:param...
1
1720
by: Lastknight | last post by:
hello all, can some bidy suggest me how to code for this problem? how to write a perl program using Apache::Session::File module? regards lastknight..
0
1098
by: Swan | last post by:
Can anyone plz tell me,Can I write file on server using binary access,or it is only to write on local?(Actually I am creating OCX for Http File Upload Control in VB using API's.So for that I need to...
5
2207
by: ajay | last post by:
Hi All, I want to build two separate EXEs using one .dsw file. That dsw file will load two different DSPs for two different projects. One project would use gcc cross compiler but other project...
1
1667
by: raul15791 | last post by:
Hi, I'm newbie in ASP. I am trying to view multiple pages by using a single file. For example, I have a few pages of product.asp (products.asp, products1.asp and so on). Now I want to create a...
1
1365
by: priyamurugar | last post by:
hi..... I wrote one server program handling many clients in java........... If the server fails, how to handle the clients.... I want to write two server programs...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.