By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Trace.WriteLine() exceedingly slow

P: n/a

I wrote a simple test program, console, that does one thing: log
DateTime.Now to a trace file.

I thought it would be lickety-split, but it's taking more than 10
minutes to write 1 million lines.

I looked at the trace and it's doing about 20 lines per second.

That's very slow.

I use Tracing a lot in my applications, and now I'm thinking its a big
overhead.
Jan 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
John Bailo wrote:

I wrote a simple test program, console, that does one thing: log
DateTime.Now to a trace file.

I thought it would be lickety-split, but it's taking more than 10
minutes to write 1 million lines.

I looked at the trace and it's doing about 20 lines per second.

That's very slow.

I use Tracing a lot in my applications, and now I'm thinking its a big
overhead.


You have many alternatives ... This are the first two that came to my mind.

One) is instead of writing each line store it in a StringBuilder (e.g.)
and when you have a reasonable amount of lines write it to the file
(This probably is faster than physically write line by line in the file)

Two) (My favorite) Use Enterprise Library Logging application block. It
is a framework specially designed for logging that can write to many
devices (file, sql server, event log ... )

Regards,
David Hernández Díez
MCDBA MCSD vs6 6 .NET
DCE5 .Net1.1 & DCE2 .NET 2.0

Jan 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.