0

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");

Edited by GAME: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by GAME
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.

Comments
Very good suggestion.
0

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?

0

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?

Edited by GAME: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.