Click here to Skip to main content
12,500,937 members (50,424 online)
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads

Stats

146.6K views
8.2K downloads
156 bookmarked
Posted

C# WPF Log4Net Viewer

, 15 Oct 2009 CPOL
Log4Net XML log viewer
LogViewer
bin
Debug
LogViewer.exe
LogViewer.vshost.exe
LogViewer.vshost.exe.manifest
LogViewer.csproj.user
LogViewer.suo
Properties
Resources
Images
arrow_left.png
arrow_right.png
find.png
Skins
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Reflection;

namespace LogViewer
{
    /// <summary>
    /// Interaction logic for About.xaml
    /// </summary>
    public partial class About : Window
    {
        public About()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            StringBuilder sbText = new StringBuilder();
            Assembly assembly = Assembly.GetEntryAssembly();
            if (assembly != null)
            {
                object[] attributes = assembly.GetCustomAttributes(false);
                foreach (object attribute in attributes)
                {
                    Type type = attribute.GetType();
                    if (type == typeof(AssemblyTitleAttribute))
                    {
                        AssemblyTitleAttribute title = (AssemblyTitleAttribute)attribute;
                        labelAssemblyName.Content = title.Title;
                    }
                    if (type == typeof(AssemblyFileVersionAttribute))
                    {
                        AssemblyFileVersionAttribute version = (AssemblyFileVersionAttribute)attribute;
                        labelAssemblyVersion.Content = version.Version;
                    }
                    if (type == typeof(AssemblyCopyrightAttribute))
                    {
                        AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)attribute;
                        sbText.AppendFormat("{0}\r", copyright.Copyright);
                    }
                    if (type == typeof(AssemblyCompanyAttribute))
                    {
                        AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)attribute;
                        sbText.AppendFormat("{0}\r",company.Company);
                    }
                    if (type == typeof(AssemblyDescriptionAttribute))
                    {
                        AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)attribute;
                        sbText.AppendFormat("{0}\r", description.Description);
                    }
                }
                labelAssembly.Content = sbText.ToString();
            }
            string text =
@"<log4net>
  <appender name=""RollingFileAppender"" type=""log4net.Appender.RollingFileAppender"">
    <file type=""log4net.Util.PatternString"" value=""c:\log\log.xml"" />
    <appendToFile value=""true"" />
    <datePattern value=""yyyyMMdd"" />
    <rollingStyle value=""Date"" />
    <layout type=""log4net.Layout.XmlLayoutSchemaLog4j"">
      <locationInfo value=""true"" />
    </layout>
  </appender>
  <root>
    <level value=""DEBUG"" />
    <appender-ref ref=""RollingFileAppender"" />
  </root>
</log4net>";
           
            this.RichTextBox1.AppendText(text);
        }

        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }        
    }
}

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

Ken C. Len
Software Developer (Senior) LEN Associates Inc.
United States United States
Years of software consulting and software development using Microsoft development products such as Microsoft Content Management System, SQL Server Reporting Service, ASP.Net C# VB.Net, HTML and javascript web development, Visual Studio add-on development, C++ MFC/ATL and COM+ development, and ActiveX components.

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 15 Oct 2009
Article Copyright 2008 by Ken C. Len
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid