trace listener - log file size & reset log file content

Hi,

I'm trying to write trace out using TextWriterTraceListener. It work
fine. But I would like to do the following 2 tasks but I can't find
any way to do it.

- Limit maximum log file size
- Refresh log file content everytime program start.

thank you very much,

Bandu
0
Bandu
1/27/2010 11:21:24 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

4 Replies
2282 Views

Similar Articles

[PageSpeed] 30

Bandu wrote:
> Hi,
> 
> I'm trying to write trace out using TextWriterTraceListener. It work
> fine. But I would like to do the following 2 tasks but I can't find
> any way to do it.
> 
> - Limit maximum log file size
> - Refresh log file content everytime program start.

To accomplish the first, you'll need to create your own TraceListener 
sub-class (perhaps inheriting TextWriter, depending on specifics), 
monitoring the output log file size and restricting the size as 
appropriate to your needs.

I don't really understand the second, not without a concise-but-complete 
code example from you demonstrating exactly what you're doing.  Seems to 
me that if you just delete the previous output file when your program 
starts, that would accomplish what you're asking for.

Pete
0
Peter
1/27/2010 11:34:52 PM
Greetings,

I believe what you're referring to is known as a "rolling" log.  Where the 
top (most recent) N number of entries are maintained between program 
executions, and older entries are dropped in the interest of file size.

If this is the case, you can find some helpful examples and open source 
solutions here:
http://csharp-source.net/open-source/logging

Google will turn up more possibilities, there are a lot of these types of 
libraries available for .Net.  I've also build my own before to address my 
particular needs, it's not too difficult.

Hope this helps,
-- 
Roger Frost
"It's all about finding the correct solution. The solution exists,
this is just software :) There are no non-solutions." -Anthony Nystrom



"Bandu" <m.bandu@gmail.com> wrote in message 
news:d947a608-6516-4827-b4a6-147e89a1adc4@b9g2000yqd.googlegroups.com...
> Hi,
>
> I'm trying to write trace out using TextWriterTraceListener. It work
> fine. But I would like to do the following 2 tasks but I can't find
> any way to do it.
>
> - Limit maximum log file size
> - Refresh log file content everytime program start.
>
> thank you very much,
>
> Bandu 

0
Roger
1/28/2010 9:12:22 AM
On 27 Jan, 23:34, Peter Duniho <no.peted.s...@no.nwlink.spam.com>
wrote:
> Bandu wrote:
> > Hi,
>
> > I'm trying to write trace out using TextWriterTraceListener. It work
> > fine. But I would like to do the following 2 tasks but I can't find
> > any way to do it.
>
> > - Limit maximum log file size
> > - Refresh log file content everytime program start.
>
> To accomplish the first, you'll need to create your own TraceListener
> sub-class (perhaps inheriting TextWriter, depending on specifics),
> monitoring the output log file size and restricting the size as
> appropriate to your needs.
>
> I don't really understand the second, not without a concise-but-complete
> code example from you demonstrating exactly what you're doing. =A0Seems t=
o
> me that if you just delete the previous output file when your program
> starts, that would accomplish what you're asking for.
>
> Pete

thanks Pete.
0
Bandu
1/28/2010 9:34:50 AM
On 28 Jan, 09:12, "Roger Frost" <fros...@hotmail.com> wrote:
> Greetings,
>
> I believe what you're referring to is known as a "rolling" log. =A0Where =
the
> top (most recent) N number of entries are maintained between program
> executions, and older entries are dropped in the interest of file size.
>
> If this is the case, you can find some helpful examples and open source
> solutions here:http://csharp-source.net/open-source/logging
>
> Google will turn up more possibilities, there are a lot of these types of
> libraries available for .Net. =A0I've also build my own before to address=
 my
> particular needs, it's not too difficult.
>
> Hope this helps,
> --
> Roger Frost
> "It's all about finding the correct solution. The solution exists,
> this is just software :) There are no non-solutions." -Anthony Nystrom
>
> "Bandu" <m.ba...@gmail.com> wrote in message
>
> news:d947a608-6516-4827-b4a6-147e89a1adc4@b9g2000yqd.googlegroups.com...
>
>
>
> > Hi,
>
> > I'm trying to write trace out using TextWriterTraceListener. It work
> > fine. But I would like to do the following 2 tasks but I can't find
> > any way to do it.
>
> > - Limit maximum log file size
> > - Refresh log file content everytime program start.
>
> > thank you very much,
>
> > Bandu- Hide quoted text -
>
> - Show quoted text -

thanks Roger.
0
Bandu
1/28/2010 9:35:10 AM
Reply:

Similar Artilces:

open file file then error message
I have excel file create in excel 2003,but I use Excel 2000 to open it The message ' File error : some number format may have been lost' How could I solve this problem (eliminate the error message) nim If you open the file in xl2k and then save the file, does the problem go away the next time you open it? Piroon Saetang wrote: > > I have excel file create in excel 2003,but I use Excel 2000 to open it > The message ' File error : some number format may have been lost' > How could I solve this problem (eliminate the error message) > > nim -- Dave Peters...

Convert pub files to word doc.
Hello I am tryign to have a visibly challenge worker who needs to read a converted publisher file. When the pub file is saves as a word file in .doc or .rft format, there are some inbuild MS text that appears. I have attached an example below. ========================================= Year 7 Study Visit 2004 This story can fit 150-200 words. One benefit of using your newsletter as a promotional tool is that you can reuse content from other marketing materials, such as press releases, market studies, and reports. While your main g...

Corrupt backup file
I get an error message that says "c:\xxx.mbf is corrupted or is not a Money backup file". Is there any hope to recovering the file? rwd In microsoft.public.money, rwdykhuis@gmail.com wrote: >I get an error message that says "c:\xxx.mbf is corrupted or is not a >Money backup file". Is there any hope to recovering the file? > > No. Search your computer for other *.mbf, *.mny files. On Jun 30, 7:52 pm, Cal Learner-- MVP <via_newsgr...@please.tnx> wrote: > In microsoft.public.money, rwdykh...@gmail.com wrote: > >I get an error message that say...

Excel 2002
I am working on a huge spreadsheet that logs thousands of transactions from dozens of customers. What I need to be able to do quickly break up that spreadsheet by customer code (column C) and save a file for every customer (along with the header) as a file named "(column C) - (column B) - (date).xls" I want it to save every file in one pass, and each file should include every column from A through P for the rows included. For example, in column C rows 2-20 the value is CAT004, 21-24 is BOB002, and 25-200 is JIL000. There should be 3 output files which should be named: CAT004 - C...

Attachment event tracing
HI, I have developed a custom form of IPM.Note Message class, the functionality goes like this, the initiator of form attaches several documents to the form and specifies the list of users to which the form has to be sent in sequence for feedback on the attached documents (which is edited and saved back to the attachments of form). This form carries these updated attachments to each user in series till the last user and then backs to the initiator. My problem is, if the user has opened the attachment and forgets to save and close, he clicks on the process button on form to next user, I need ...

Cannot save Project file as MS Access file
I want a MS Access version of my Project file that is actively linked. I assume that since my project file consists of several sub-projects that I can get a linked Access file simply by saving the project file in MS Access format. I can save the project file as an Access file type, but then when I go to open it in Access it says unrecognizable format. I am using Access 97 and Project 2003. How can I get a linked version of my project file in database format? This being an Excel news group will probably lead to few answers about Project or Access. Here's a list to all microsoft...

Opening Outlook Data Files. (PST)
I used to work for a company that had n Linux Mail Server with Internet Mail set up on my Outlook 2002. I moved to a company that run Exchange for mail also with Outlook 2002 installed om my PC. When I try to open the PST File I saved from my last company, it gives me an error message: Files access is denied. You do not have the permission required to access the file c:\..... It gives the same message when I try and import the file. Is this because the PST file is from Linux or what could the problem be. In article <8cda01c34580$7209c840$a401280a@phx.gbl>, eugenem@frenchconnect...

Outlook pst file
My original pst file was about 30 mb in size. Somehow it is corrupted and showing only 30 kb in size. I am not able to recover my previous info. Is there any way to retrieve info from this pst. You could try the inbox repair tool, scanpst.exe David "Ajay" <ajayget@indiatimes.com> wrote in message news:07e301c358de$6534d0d0$a101280a@phx.gbl... > My original pst file was about 30 mb in size. Somehow it > is corrupted and showing only 30 kb in size. I am not able > to recover my previous info. Is there any way to retrieve > info from this pst. ...

attaching files in Outlook
One user in our office is frequently getting the following error: -The property does not exist. The field you want to modify is not valid for this type of item.- He gets this error when trying to add attachments, remove attachments or send a message with attachments. It does not happen all the time. When it happens when he's trying to send the message, he can try again and it will send successfully; but the recipient does not always receive the attachment. Has anybody else had this problem or know what to do to fix it? He's usings Win XP Pro with Office XP Small Business. All of ...

How to write a data in Excel file dynamically from C / VC++
Hi, Very Urgent... I Need to write a structure of data which is in "C" to excell file. So, using C/VC++ how i can create a Excel file and how i can write a data into the respective cell at run time. Pls help on this , Would be great if some samples provided. Thanks, Sweety ...

File Association
I am using Office 2003. I have some old files that have no file extension. Word or Excel does not recognise them and if I give them a .doc extension I get a message "Word cannot start the converter MSWRD632.WPC. Is there any way to identify these files in a useful manner? Click the Fixit button at http://support.microsoft.com/kb/973904 then if these are Word compatible documents, you may be able to open them. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My we...

TRACE
Hi, Could you tell me which is the Win32 [or perheps, more correctly, non-MFC] equivalent of MFC's TRACE macro. Thanks very much. -- ====== Arman I think you can use OutputDebugString() in a purely win32 application. -Seetharam Misro Ok, it worked. Thanks. -- ====== Arman "Seetharam" wrote: > I think you can use OutputDebugString() in a purely win32 application. > > -Seetharam Misro > > There isn't really one that has the properties of formatting, conditional compilation, and output to the debug port. OutputDebugString is the Win32 API, ...

Help! Help content lost (links to 2010?)
When I try to get online Help from Word, I see a page which has the new Office logo for 2010. The framework for Help is provided, but there is no content under any of the headings. ("No results available"). This was from a VBA page, so I was seeking Word Developer help. If I right-click the title "Word Developer Help" and paste the URL property, I get: http://office2010.microsoft.com/client/helphome.aspx?lcid=3081&NS=WINWORD%2EDEV&Version=12 But I'm running Office 2007. I also have Office 2003 installed. How can I get help for Word 2007? Fur...

how to zip a file from VBA
Hi, I would like to write a code that will zip a file. I would like to be able to specify the source file (e.g. Data.txt) and specify the name of the zip file (e.g. Data.zip). How can I do this? I am using access 2007. thanks! http://www.databasejournal.com/features/msaccess/article.php/3835766/Working-with-Compressed-zipped-folders-in-MS-Access.htm -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "Boon" <boonyawat.la-ongthong@cnh.com> wrote in message news:eXdcLuyqKHA.3536@TK2MSFTNGP06.phx.gbl... >...

Publisher changes the default paper size before I print
I go to page setup and change to 5 x 7 (as I am makeing a postcard of that size). I create the document. Then I go to print. I make sure the paper size under page set-up and on my printer is "index card 5 x 8" I hit print. The printer or program has changed the papersize to 8.5 x 11 and my pre-cut postcards are ruined. What is the issue here? Does anyone know? What are the dimensions of your pre-cut card? If there are two cards per page, use the postcard half page setting. If you are setting up your printer for 5 x 8 then the printer is expecting stock that is 5 x 8. If ther...

MSCRMMobileSubscriptions.mdf keeps growing in size
Hi, We have CRM Mobile installed and have found that the MSCRMMobileSubscriptions.mdf has doubled in size from 2GB to 4GB in a few months, we have also noticed that it keeps growing in size, and we don't actually use it. Any ideas on why it would keep growing so rapidly with no use of it? Thanks I there we have the same problem. Any luck with this Thanks Kuven "SophieK" wrote: > Hi, > > We have CRM Mobile installed and have found that the > MSCRMMobileSubscriptions.mdf has doubled in size from 2GB to 4GB in a few > months, we have also noticed that it...

Database file size
I just looked at the properties screen for our main database and saw it was at 90% capacity. Not sure what would happen if it got to 100%, but probably should do something? What's best to do...delete old journals, inactive items and suppliers. How do I delete transaction history? Does it get archived? Thanks! You're getting ahead of yourself.. It will always be at 90% capacity (with 10% growth space) as it grows. The overall file size is what you need to be concerned with. You may want to research how SQL databases grow (autogrow) to fully understand what that 90% / 10%...

excel found unreadable content 03-04-10
I created a worksheet, with very simple formulas, saved in Excel 97-2003, had re-opened and made changes to the file several times, then today I try and open the file and it stated that Excel found unreadable content and asked if I wanted to recover content. So I click yes, and then another error message stated that excel was able to recover formulas but some data in the cells may have been lost. So my entire document is blank. The data are very important and would really like some help figuring out how to recover the file! Please. Thanks Some people have said that using OpenO...

Opening file when file name is always different
Using Excel 97 on WINNT Each fortnight I receive a report which is then formatted and save using a dated filename for the next Wednesday e.g. "570 Repor 28-07-2004". Next period, this report will be automatically saved as 570 Repor 11-08-2004". I use the code: "G:\ER\570 report " & Format(date+4-weekday(date), "dd-mm-yyyy") ".xls" which was kindly supplied by Dave Peterson. I am now trying to compare fortnightly reports and was wondering i there is a way to call the current report and the previous fortnightl report using VBA as part of a mac...

PST file size exceeded
If you exceed the 2.0gig file size on personal folders, how do you recover it in Outlook 2000? See this page: http://www.slipstick.com/problems/repair2gbpst.htm -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "chuber" <anonymous@discussions.microsoft.com> wrote in message news:051201c3a922$7cc76390$a001280a@phx.gbl... > If you exceed the 2.0gig file size on personal folders, > how do you recover ...

Why meta file looks different from DIB?
Hi, I'm doing something with windows meta file and meet some problems. I use ::CreateMetaFile(...), ::StretchDIBits(...) and ::CloseMetaFile(...) to create a memory meta file with the same content as DIB. Then I make a METAFILEPICT struct and use CF_METAFILEPICT format for drag and drop support to other applications, like Excel2000, because it does not support CF_DIB format. The problem is like this, I use an original DIB of 256*256 pixels, with each pixel RGB(128,128,128). After creating the meta file, I use ::GetMetaFileBitsEx(...) and find the corresponding BYTEs are 0x80,0x...

tracing precedents and dependents
HI folks, I'm using the auditing tool to trace precedents and dependents to a cell. Problem is if the precedent or dependents are on another sheet, it won't tell me which sheets and which cells are dependent to the cell I am examining. Is there a way to find this out? any improvements to this tool out there? thanks Just doubleclick on the line linking the little spreadsheet box you can see -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ------------------------------------------------------------...

open a file
how to open(view) a file in read oly mode. i 'ed try using ShellExecute(), but it will not work in read only mode. How about showing the file in a read-only edit box? Why do you have to open another program to show a file? I assume a text-file here. -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "sajeev" <sajeevkumar.sajeev@gmail.com> wrote in message news:64cbdddf.0504260236.2052db3e@posting.google.com... > how to open(view) a file in read oly mode. > i 'ed try using ShellExecute(), but it will not work in read only mode. ...

Publisher web files
I have a friend who wants me to do her website. I have FrontPage and will use that for the site but I am curious about something. She has a catalog she created using Word. I need to break it down into product lines so it's going to take me some time. Let's say I decided to try the new catalog merge feature for Pub 2003 and then save that as the site. What kind of issues am I likely to encounter? I'm not saying this is what I will do, I'm just thinking that maybe I can do some of the work in Publisher, which I'm very comfortable using, and then switch it to FP, which I'...

Openning Excel by double clicking on the file name in Explorer
MS Excel opens only as a Excel but not a particular file when double clicked on the file name in Explorer. It opens only from the File Open window in Excel itself. How can I fix it? Hi Try going to Tools|Options|General and unchecking 'Ignore Other Applications' -- Andy. "Joseph" <Joseph@discussions.microsoft.com> wrote in message news:AFDB77F6-D218-49D8-A2E1-B88B00266761@microsoft.com... > MS Excel opens only as a Excel but not a particular file when double > clicked > on the file name in Explorer. It opens only from the File Open window in > E...