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 8470275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:28:18+00:00 2026-06-10T16:28:18+00:00

Today im writing the logging to a text file log: /*—————————————————————- * Module Name

  • 0

Today im writing the logging to a text file log:

/*----------------------------------------------------------------
 * Module Name  : Logger
 * Description  : A logger
 * Author       : Danny
 * Date         : 10/02/2010
 * Revision     : 1.00
 * --------------------------------------------------------------*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
/*
 *  Introduction :
 * 
 *  This module is a logger. any module can use this 
 *  module to log its actions.
 * 
 * 
 * */

        /*----------------------------------------
         *   P R I V A T E    D E F I N I T I O N S 
         * ---------------------------------------*/


namespace DannyGeneral
{
    class Logger
    {
        /*----------------------------------------
         *   P R I V A T E     C O N S T A N T S 
         * ---------------------------------------*/
        static string log_file_name = @"\logger.txt";
        static string full_path_log_file_name;
        static string path_log;
        static Mutex mut;
        /*----------------------------------------
         *   P R I V A T E     V A R I A B L E S 
         * ---------------------------------------*/

        /*---------------------------------
         *   P U B L I C   M E T H O D S 
         * -------------------------------*/

        /*----------------------------------------------------------
         * Function     : Logger
         * Description  : static Constructor
         * Parameters   : none
         * Return       : none
         * --------------------------------------------------------*/
        static Logger()
        {
            mut = new Mutex();
            path_log = Path.GetDirectoryName(Application.LocalUserAppDataPath)+ @"\log";
            if (!Directory.Exists(path_log))
            {
                Directory.CreateDirectory(path_log);
            }
            full_path_log_file_name = path_log + log_file_name;
        }

        /*----------------------------------------------------------
         * Function     : Write
         * Description  : writes a string to the log file
         *                This functions will add time and date and
         *                end of line chars to the string written to
         *                the file.
         * Parameters   : string to write to the file.
         * Return       : none
         * --------------------------------------------------------*/
        public static void Write(string str)
        {
            if (mut.WaitOne() == false)
            {
                return;
            }
            else
            {

                using (StreamWriter sw = new StreamWriter(full_path_log_file_name, true))
                {
                    sw.Write(DateTime.Now.ToShortDateString() + "--" + DateTime.Now.ToShortTimeString() + " ==> " + str);
                    sw.WriteLine();
                    sw.Close();
                }
            }
            mut.ReleaseMutex();
        }
        public static void exist()
        {
            if (!File.Exists(path_log + log_file_name))
            {
                StreamWriter sw = new StreamWriter(path_log + log_file_name);
                sw.Write(DateTime.Now.ToShortDateString()+"--"+DateTime.Now.ToShortTimeString()+" ==> "+"First Time The Log File Was Created"+Environment.NewLine);
                sw.WriteLine();
                sw.Close();
            }
        }
        public static void newEmptyLine()
        {
            StreamWriter sw = new StreamWriter(path_log + log_file_name,true);
            sw.WriteLine();
            sw.Close();
        }

        public static string LoggerPath()
        {
            string path = path_log + log_file_name;
            return path;
        }

        /*---------------------------------
         *   P R I V A T E    M E T H O D S 
         * -------------------------------*/

    }



}

Instead to write it to a simple text file and viewing the file while the program is running using Process and notepad.exe i thought maybe there is another way to view the log file but with colors inside ? Something like richTextBox so i can paint in the file each line in another color.

And that it will be opened fast like it does now with notepad.

  • 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-10T16:28:20+00:00Added an answer on June 10, 2026 at 4:28 pm

    You can’t have a text file “with colors”. Plain text does not have formatting.

    You will need to write as a format that does have formatting – RTF or HTML for example will work.

    You may be able to customize your logs and a programming editor (notepad++ for example) to do some syntax highlighting for you.

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

Sidebar

Related Questions

When writing some rspec today, I came across some unexpected behavior with comparing Date
I am very new (started today) to writing chrome extensions but need to write
Today I was writing a little Memory Profiler for my code and for the
Today I am writing a small program in Haskell. I found that in ghci's
So I was writing some queries today and was using top 10 on a
I started writing functional tests for my rails app today. I use the RESTful
As I was writing a for loop earlier today, I thought that there must
What I read today about UNIX's pipes: If multiple processes are writing to a
I'm writing bug tracking software in PHP, and today I saw this in another
Today, I have started writing a query which is as given below: SELECT IP1.InstId,CAST(IP2.Quote

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.