-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: SoftwareAkash
Message 4 in Discussion
Hi I was actually using log4net earlier, but I found that it has a lot of
problems, like sometimes it does not log at all without any reasons. So later
I decided to write a small logging class myself. I am actually using locking
and synchronisation both but still getting the same error here is my code for
your consideration
////////////////////////////////////////////////////////////////////////////
static void WriteToLog(string LogString, string LogLevel)
{
//Create a log format : dd/mm/yyyy hh:mm:ss AM/PM [LogLevel]==> Log Message
// And writing to the file
string sLogFormat = DateTime.Now.ToShortDateString().ToString() + " " +
DateTime.Now.ToLongTimeString().ToString() + " [" + LogLevel + "]" + " ==> ";
StreamWriter sw = new StreamWriter(FullFilePath, true);
TextWriter tw = TextWriter.Synchronized(sw);
tw.WriteLine(sLogFormat + LogString);
tw.Flush();
tw.Close();
tw.Dispose(); } ////////////////////////////////////////////////////// The
actual thing happening is this
1) I call this fuction ( DLL ) from 2 applications. First Application is an
ASp.net Web Application and the second one is a conslole application. both
writes 10000 lines in the log file. ( it takes around 5 seconds for a web app
and 10-15 seconds for a console app to write 10000 entries)
2) I first start any one application and after that I start the other one. The
second application waits for the first application to finish ( that is ... the
first application writes to the log successfully ). But when the second
application tries to start writing I get error of " the file is being used by
other process.
I have tried 2 web applications and 2 console applications also .. but the
result is the same. any clue on what an error might be? thanks Akash
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]