954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Creating a log.

How would I create a log.
What I would like to do is have the program start up and show the real time and a message.

the code i have so far from searching.

DateTime.Now.ToString("hh:mm:ss tt");
GAME
Junior Poster
166 posts since Mar 2010
Reputation Points: 5
Solved Threads: 1
 

I would recommend to use the log4net framework, instead of writing your own custom logging solution. You can visit the log4net website, here: http://logging.apache.org/log4net/index.html

Follow the documentation to set it up, and check out the examples they have. With it, you can log to the console, to the debug window, to an XML file, and even to the Windows Event Log.

Tekmaven
Software Architect
Moderator
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
 

Your question seems a bit ambiguous. Did you mean creating a log file, as Tekmaven gave you a suggestion on how to do it, or do you simply want a message to be shown (like: Good morning John, it is 08:15 AM) at your program startup?

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

Yes you are correct, I finally got that code to work.
I get some errors with this code any suggestions?

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Xml.Linq;

namespace XML_News
{
	public partial class News
	{

		public string GetNews(string xmlUrl)
		{
			try
			{
				System.Text.StringBuilder NewsBuilder = new System.Text.StringBuilder();
				XDocument NewsFeed = XDocument.Load(xmlUrl);
				foreach (XElement Element in NewsFeed...<root>...<NewsFeed>...<news>)
				{
					NewsBuilder.Append(((char)(61623)).ToString() + " " + Element.Value + System.Environment.NewLine + System.Environment.NewLine);
				}
				return NewsBuilder.ToString();
			}
			catch (Exception ex)
			{
				return "Could not retrieve news, " + ex.Message;
			}
		}


How can I create a XML page?

GAME
Junior Poster
166 posts since Mar 2010
Reputation Points: 5
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You