Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. LogConsole? Recommendations?

LogConsole? Recommendations?

Scheduled Pinned Locked Moved C#
cssdatabasequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tkrn
    wrote on last edited by
    #1

    Alright, I have a log console that i have created that is specific for my multi-form application. It is a grid view with methods to write to that grid view, in the event of an Exception, it will take that information then write it to the system log. But, my concept is to have the log console instantiated from the beginning and just toggling the visibility of the form. I've been playing around and reading on the internet different ways to do what i am looking on doing but have not had much luck being able to access that specific method LogConsole.WriteLine(string) other than where it has been instantiated. This would be more of debugging console kinda of, but is ment for the IT people with in my company to be able to pin-point future issues, the log will display, errors, informational sql connection information, etc, etc. Any suggestions to put me in the right direction?

    M W 2 Replies Last reply
    0
    • T tkrn

      Alright, I have a log console that i have created that is specific for my multi-form application. It is a grid view with methods to write to that grid view, in the event of an Exception, it will take that information then write it to the system log. But, my concept is to have the log console instantiated from the beginning and just toggling the visibility of the form. I've been playing around and reading on the internet different ways to do what i am looking on doing but have not had much luck being able to access that specific method LogConsole.WriteLine(string) other than where it has been instantiated. This would be more of debugging console kinda of, but is ment for the IT people with in my company to be able to pin-point future issues, the log will display, errors, informational sql connection information, etc, etc. Any suggestions to put me in the right direction?

      M Offline
      M Offline
      Mustafa Ismail Mustafa
      wrote on last edited by
      #2

      Have you considered creating a form that would always be on top in your main method? Creating it from the start, then all the other windows would be under your control as well but would be fired up after the creation of your logging form. This is assuming that I've understood your problem correctly.

      Sig history "You're an idiot." John Simmons, THE Outlaw programmer "I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon Unix is a Four Letter Word, and Vi is a Two Letter Abbreviation

      1 Reply Last reply
      0
      • T tkrn

        Alright, I have a log console that i have created that is specific for my multi-form application. It is a grid view with methods to write to that grid view, in the event of an Exception, it will take that information then write it to the system log. But, my concept is to have the log console instantiated from the beginning and just toggling the visibility of the form. I've been playing around and reading on the internet different ways to do what i am looking on doing but have not had much luck being able to access that specific method LogConsole.WriteLine(string) other than where it has been instantiated. This would be more of debugging console kinda of, but is ment for the IT people with in my company to be able to pin-point future issues, the log will display, errors, informational sql connection information, etc, etc. Any suggestions to put me in the right direction?

        W Offline
        W Offline
        wurzel_cidermaker
        wrote on last edited by
        #3

        Here's one way, create a test project with:- 2 Forms (Form1 and DebugWindow) 1 "Logger" class. Form1 just has 2 buttons on it, 1 to write an entry to the "Logger" class, the other to "Show" the Debug form. The DebugWindow form just has a Listbox on it. The Logger class has a static method which can be called from any class in your project, which in turn writes an entry in your DebugWindow listbox. Here's the Form1 class. <<< public partial class Form1 : Form { DebugWindow dbug; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { dbug = new DebugWindow(); dbug.Show(); Logger.DebugWindow = dbug.DebugListBox; } private void button1_Click(object sender, EventArgs e) { Logger.LogIt(DateTime.Now.ToString("dd MM yyyy HH:mm:ss.fff")); } private void button2_Click(object sender, EventArgs e) { dbug.Show(); } } >>> Here's the DebugWindow class. <<< public partial class DebugWindow : Form { private ListBox _debugListbox; public DebugWindow() { InitializeComponent(); } // // hide form // private void hideToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); } // // Properties // public ListBox DebugListBox { get { return _debugListbox; } set { _debugListbox = value; } } private void DebugWindow_Load(object sender, EventArgs e) { DebugListBox = listBox1; } } >>> Here's the Logger class. <<< class Logger { private static ListBox _debugWindow; // // Log Message // public static void LogIt(string sData) { sData = sData.Trim(); UpdateListBox(sData); } // // output to listbox // delegate void ListBoxStringAdder(string sInfp); private static void UpdateListBox(string sInfo) { int iLines = 999; if (DebugWindow.InvokeRequired) { ListBoxStringAdder lsa = new ListBoxStringAdder(UpdateListBox); DebugWind

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups