Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 234367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:10:45+00:00 2026-05-11T20:10:45+00:00

OK, here’s a good one (I think) – I’m working on an application with

  • 0

OK, here’s a good one (I think) – I’m working on an application with lots (far too many) dependency dlls, created by a team of developers. I’m trying to debug just one assembly, but the console output is ‘polluted’ by the Console.WriteLines and Debug.WriteLines left scattered around the code.

Is there anyway I can work out exactly which assembly a given line is coming from, so I can get the author to clean up their source?

UPDATE If you’re also experiencing this kind of issue, note that there is another potential source of output messages which is any breakpoints with ‘When hit’ set to print a message. Having said which, this is a VERY cool feature, which can prevent the kind of problems I was having above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:10:46+00:00Added an answer on May 11, 2026 at 8:10 pm

    Yes – replace Console.Out. Use Console.SetOut after creating a TextWriter which not only dumps the requested data to the original console, but also dumps a stack trace (and timestamp, and the requested data) to a file.

    Here’s some code, adapted from Benjol’s answer:

    (Note: you will want to adapt this code depending on whether you want a stack trace after each write, or after each writeline. In the code below, each char is followed by a stack trace!)

    using System.Diagnostics;
    using System.IO;
    using System.Text;
    
    public sealed class StackTracingWriter : TextWriter
    {
        private readonly TextWriter writer;
    
        public StackTracingWriter (string path)
        {
            writer = new StreamWriter(path) { AutoFlush = true };
        }
    
        public override System.Text.Encoding Encoding
        {
            get { return Encoding.UTF8; }
        }
    
        public override void Write(string value)
        {
            string trace = (new StackTrace(true)).ToString();
            writer.Write(value + " - " + trace);
        }
    
        public override void Write(char[] buffer, int index, int count)
        {
            Write(new string(buffer, index, count));
        }
    
        public override void Write(char value)
        {
            // Note that this will create a stack trace for each character!
            Write(value.ToString());
        }
    
        public override void WriteLine()
        {
            // This is almost always going to be called in conjunction with
            // real text, so don't bother writing a stack trace
            writer.WriteLine();
        }
    
        protected override void Dispose(bool disposing)
        {
            writer.Dispose();
        }
    }
    

    To use this for logging both Console.WriteLine and Debug.WriteLine to a file, make calls like this as early as possible in your code:

    var writer = new StackTracingWriter(@"C:\Temp\ConsoleOut.txt");
    Console.SetOut(writer);
    Debug.Listeners.Add(new TextWriterTraceListener(writer));
    

    Note that this currently doesn’t also write to the original console. To do so, you’d need to have a second TextWriter (for the original console) in StackTracingWriter, and write to both places each time. Debug will however continue to be written to the original console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 245k
  • Answers 245k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This will return what you're looking for I think... $("input:hidden,… May 13, 2026 at 8:09 am
  • Editorial Team
    Editorial Team added an answer If this is a local clone, then the clone may… May 13, 2026 at 8:09 am
  • Editorial Team
    Editorial Team added an answer Garbage Collection is used in many production quality applications. Xcode,… May 13, 2026 at 8:09 am

Related Questions

Ok, here's the breakdown of my project: I have a web project with a
Ok, here's one for the JavaScript gurus: In my app, one of the controllers
Ok, I know someone here has tried this ninja-elite level of coding before. Essentially
Ok guys and gals, here is my problem: I've built a custom control that
OK, Here is my problem, I have a master page with a HEAD section

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.