LogConsole? Recommendations?
-
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?
-
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?
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
-
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?
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