473,395 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

RTF log file

I need a log file, and RTF is good since color formatting can help
find the interesting parts. I want something that I can code quick.
Would the easiest way be to write to a hidden RichTextBox, grab the
RTF code from it, and write it to a file on shut down? Likely, I'll
have an option to view the loggin onscreen at the same time, so I may
or may not have a RichTextBox already showing the contents on the
screen. Perhaps I could just make it the same one, but then the log
class needs to be aware of the GUI. I'd rather have it just create
its own RichTextBox internally, *if* that is the best way.

Or, I could just code my own (very simple one) like this, which allows
only basic formatting, which is all I need:
http://www.gamedev.net/reference/pro...atures/rtflog/

Any thoughts?

Zytan

Mar 2 '07 #1
5 2272
Any thoughts?
For logging purposes you can use System.Diagnostic.Trace. It gives you all
the flexibility you need and it can be configured in the application .config
file. You can write plain text to it, so RTF (or HTML, XML, ...) is
possible, though you have to format it yourself.
There are a lot of good examples about System.Diagnostic.Trace, for example
at http://www.15seconds.com/issue/020910.htm

To see the logging onscreen also you could use a FileSystemWatcher on the
logfile. This is a bit tricky, especially when you trace something from the
onscreen logview. You could also derive your own class from TraceListener (I
sent you an example earlier this week ) and provid it with an event to which
the onscreen logview (or an e-mail object, pager object, SMS object, ...)
can subscribe.

Regards,
Anne

Mar 2 '07 #2
For logging purposes you can use System.Diagnostic.Trace. It gives you all
the flexibility you need and it can be configured in the application .config
file. You can write plain text to it, so RTF (or HTML, XML, ...) is
possible, though you have to format it yourself.
There are a lot of good examples about System.Diagnostic.Trace, for example
at http://www.15seconds.com/issue/020910.htm
Ok, thanks for this link. It's great! I see an error in his first
bit of code, he adds a trace listener, but doesn't remove it,so
subsequent calls to Debug.WriteLine will throw an exception when
attempting to log to the closed file. He needs to add:

Trace.Listeners.Remove(objTraceListener);

Anyway, this is just what I want. thanks.
To see the logging onscreen also you could use a FileSystemWatcher on the
logfile. This is a bit tricky, especially when you trace something from the
onscreen logview. You could also derive your own class from TraceListener (I
sent you an example earlier this week ) and provid it with an event to which
the onscreen logview (or an e-mail object, pager object, SMS object, ...)
can subscribe.
Sounds complicated.

The tracing will be present in the release build, and I can see that
Trace = Debug except that Debug is removed from release, so I will use
Trace. And i want log files to be made always. But, to show them at
the same time? I think your second option is best, to make my own
TraceListener, which can be given a control to log to as well, if
desired.

Thanks!!

Zytan

Mar 2 '07 #3
For logging purposes you can use System.Diagnostic.Trace.
[snip]
You can write plain text to it, so RTF (or HTML, XML, ...) is
possible, though you have to format it yourself.
Yup, that's too bad, but I guess it's not that big of a deal, as I
said, this link shows how to do it in an easy way:
http://www.gamedev.net/reference/pro...atures/rtflog/

But, it'd be nice to not get my hands dirty with that.

Maybe I need a wrapper, that takes a font, color, and string, and will
write them all as RTF to the log file, and passes just the string to
Trace/Debug.

Zytan

Mar 2 '07 #4
bob
Hi Zytan,
I would tend towards isolating the formatting from the file.
i.e. Make, say, the first char of each line a status char.
When you come to display, read in the file and use the status char to setup
your formatting.
HTH
Bob

"Zytan" <zy**********@yahoo.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
I need a log file, and RTF is good since color formatting can help
find the interesting parts. I want something that I can code quick.
Would the easiest way be to write to a hidden RichTextBox, grab the
RTF code from it, and write it to a file on shut down? Likely, I'll
have an option to view the loggin onscreen at the same time, so I may
or may not have a RichTextBox already showing the contents on the
screen. Perhaps I could just make it the same one, but then the log
class needs to be aware of the GUI. I'd rather have it just create
its own RichTextBox internally, *if* that is the best way.

Or, I could just code my own (very simple one) like this, which allows
only basic formatting, which is all I need:
http://www.gamedev.net/reference/pro...atures/rtflog/

Any thoughts?

Zytan

Mar 2 '07 #5
Hi Zytan,
I would tend towards isolating the formatting from the file.
i.e. Make, say, the first char of each line a status char.
When you come to display, read in the file and use the status char to setup
your formatting.
HTH
Bob
Great idea, Bob! This lets me use the tracing classes basically as-
is.

But I still would like to view the log files from outside of the app.
That's mostly how they will be used. I'd have to make a quick little
app to view them properly. With RTF, I wouldn't have any issues.

Zytan

Mar 2 '07 #6

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

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
0
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a...
0
by: thjwong | last post by:
I'm using WinXP with Microsoft Visual C++ .NET 69462-006-3405781-18776, Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1 Most developers...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.