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

  • SEARCH
  • Home
  • 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 8209257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:39:39+00:00 2026-06-07T09:39:39+00:00

I’m writing a WinForms application. I need to log information into a file. Usually

  • 0

I’m writing a WinForms application. I need to log information into a file. Usually I use log4net for logging, but I cannot add the reference, due to a restriction. I cannot add external references to my project, because I must deploy a single executable.

Is there any built-in logging framework in .NET so I will be able to log into a file without adding an external dll?

P.S: Of course I don’t wanna open a stream and write manually.

  • 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-06-07T09:39:41+00:00Added an answer on June 7, 2026 at 9:39 am

    Yes, the System.Diagnostics.TraceListener class. You will need to define the TRACE constant for it to work, but you can use a number of built in tracelisteners, through configuration of your app.config:

    • ConsoleTraceListener Class
    • EventLogTraceListener Class
    • XmlWriterTraceListener Class
    • TextWriterTraceListener Class

    The app.config looks something like this if you want to write to a file, there are a lot of filters you can also add:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.diagnostics>
            <trace autoflush="false" indentsize="4">
              <listeners>
                <add name="yourName" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\mylogfile.txt" />
              </listeners>
            </trace>
        </system.diagnostics>
    </configuration>
    

    And usage:

    Trace.TraceError("There's been an error captain: {0}", e);
    Trace.TraceWarning("The system broke but don't worry.");
    Trace.TraceInformation("Starting up the engines.");
    

    Personally I wouldn’t write to a text file if you can avoid it, the Event Log is a better location as you can sort, filter, the logs are auto-purged and you don’t get file lock up issues.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

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.