Click here to Skip to main content
12,352,855 members (71,901 online)
Click here to Skip to main content
Articles » Languages » XML » Utilities » Downloads

Stats

44.8K views
1.4K downloads
41 bookmarked
Posted

Use XML for Log Files

, 21 Aug 2008 CPOL
How to use XML to write and read log files.
namespace NRSoftware.XMLforLogFiles
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.textBoxNameForLogFile = new System.Windows.Forms.TextBox();
            this.buttonCreateLogfile = new System.Windows.Forms.Button();
            this.buttonReadLogfile = new System.Windows.Forms.Button();
            this.label2 = new System.Windows.Forms.Label();
            this.dataGridViewLogfile = new System.Windows.Forms.DataGridView();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.label3 = new System.Windows.Forms.Label();
            this.textBoxRawContents = new System.Windows.Forms.TextBox();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewLogfile)).BeginInit();
            this.tableLayoutPanel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label1.Location = new System.Drawing.Point(3, 0);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(261, 30);
            this.label1.TabIndex = 0;
            this.label1.Text = "&Name for Logfile :";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // textBoxNameForLogFile
            // 
            this.textBoxNameForLogFile.Dock = System.Windows.Forms.DockStyle.Fill;
            this.textBoxNameForLogFile.Location = new System.Drawing.Point(3, 33);
            this.textBoxNameForLogFile.Name = "textBoxNameForLogFile";
            this.textBoxNameForLogFile.Size = new System.Drawing.Size(261, 20);
            this.textBoxNameForLogFile.TabIndex = 1;
            this.textBoxNameForLogFile.Text = "c:\\testlog.xmllog";
            // 
            // buttonCreateLogfile
            // 
            this.buttonCreateLogfile.Dock = System.Windows.Forms.DockStyle.Fill;
            this.buttonCreateLogfile.Location = new System.Drawing.Point(270, 3);
            this.buttonCreateLogfile.Name = "buttonCreateLogfile";
            this.buttonCreateLogfile.Size = new System.Drawing.Size(261, 24);
            this.buttonCreateLogfile.TabIndex = 2;
            this.buttonCreateLogfile.Text = "&Create Logfile";
            this.buttonCreateLogfile.UseVisualStyleBackColor = true;
            this.buttonCreateLogfile.Click += new System.EventHandler(this.buttonCreateLogfile_Click);
            // 
            // buttonReadLogfile
            // 
            this.buttonReadLogfile.Dock = System.Windows.Forms.DockStyle.Fill;
            this.buttonReadLogfile.Location = new System.Drawing.Point(270, 33);
            this.buttonReadLogfile.Name = "buttonReadLogfile";
            this.buttonReadLogfile.Size = new System.Drawing.Size(261, 24);
            this.buttonReadLogfile.TabIndex = 3;
            this.buttonReadLogfile.Text = "&Read Logfile";
            this.buttonReadLogfile.UseVisualStyleBackColor = true;
            this.buttonReadLogfile.Click += new System.EventHandler(this.buttonReadLogfile_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(3, 60);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(126, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Raw C&ontents of Log File\r\n";
            // 
            // dataGridViewLogfile
            // 
            this.dataGridViewLogfile.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.tableLayoutPanel1.SetColumnSpan(this.dataGridViewLogfile, 2);
            this.dataGridViewLogfile.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridViewLogfile.Location = new System.Drawing.Point(3, 210);
            this.dataGridViewLogfile.Name = "dataGridViewLogfile";
            this.dataGridViewLogfile.Size = new System.Drawing.Size(528, 101);
            this.dataGridViewLogfile.TabIndex = 6;
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.label2, 0, 2);
            this.tableLayoutPanel1.Controls.Add(this.buttonReadLogfile, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.textBoxNameForLogFile, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.buttonCreateLogfile, 1, 0);
            this.tableLayoutPanel1.Controls.Add(this.dataGridViewLogfile, 0, 5);
            this.tableLayoutPanel1.Controls.Add(this.label3, 0, 4);
            this.tableLayoutPanel1.Controls.Add(this.textBoxRawContents, 0, 3);
            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 6;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(534, 314);
            this.tableLayoutPanel1.TabIndex = 7;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(3, 187);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(80, 13);
            this.label3.TabIndex = 7;
            this.label3.Text = "Read with XML";
            // 
            // textBoxRawContents
            // 
            this.tableLayoutPanel1.SetColumnSpan(this.textBoxRawContents, 2);
            this.textBoxRawContents.Dock = System.Windows.Forms.DockStyle.Fill;
            this.textBoxRawContents.Location = new System.Drawing.Point(3, 83);
            this.textBoxRawContents.Multiline = true;
            this.textBoxRawContents.Name = "textBoxRawContents";
            this.textBoxRawContents.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.textBoxRawContents.Size = new System.Drawing.Size(528, 101);
            this.textBoxRawContents.TabIndex = 8;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(534, 314);
            this.Controls.Add(this.tableLayoutPanel1);
            this.Name = "Form1";
            this.Text = "XMLForLogfiles";
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewLogfile)).EndInit();
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox textBoxNameForLogFile;
        private System.Windows.Forms.Button buttonCreateLogfile;
        private System.Windows.Forms.Button buttonReadLogfile;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.DataGridView dataGridViewLogfile;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox textBoxRawContents;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Norbert Ruessmann
freelance developer
Germany Germany
I studied physics at the university of cologne. After university I somehow got into software developemnt, starting with the Apple II.
Today I am focused on Windows developement using C# / .NET (Forms, ASP.NET, WPF) and sometimes C++.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 22 Aug 2008
Article Copyright 2008 by Norbert Ruessmann
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid