Closed Thread
Results 1 to 4 of 4

Thread: C# - Need Help in code for logging

  1. #1
    JDomo is offline Newbie
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    C# - Need Help in code for logging

    Hi everyone,

    I a newbie for C# programming, current I m given a project on server - clients system using C#. I able to come out with a multithreads server - clients system.

    Now I need to record/keep track of the data that I send from the clients side to the server side.

    May I know what program to use? As in must I use EVENT LOG? or just some Read/Write text that will add to the clients code?

    I am lost, I really don't know what to do next..

    Some samples or links that I can refer too will be good.

    Thanks in advance.
    Newbie; JDomo

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: C# - Need Help in code for logging

    Depending on the type of data, you may want a database, event log, or something else.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    JDomo is offline Newbie
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Re: C# - Need Help in code for logging

    For what type of data, i still not so sure right now, but i need to so a demo type, so i guess i am using some string and int to display..

    So i guess Event log will best suit my project?

    So there is another question to event log, how am i going to link the client massage to the event log? As in i need to record down what i send to the server as for a counter checking purpose.

    Here is my client program; hope anyone of you guys can give me a helping hand.

    // Client Program

    using System;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Net.Sockets;


    public class clnt {

    public static void Main() {

    try {
    // Hot Key
    Console.WriteLine("Command: ");
    Console.WriteLine("Press [enter] after completed a string");
    Console.WriteLine("Type [exit] to exit from the sever");

    TcpClient tcpclnt = new TcpClient();
    Console.WriteLine("\nConnecting to Server...");
    Boolean running = true;

    tcpclnt.Connect("127.0.0.1", 8001);
    // use the ipaddress as in the server program, "127.0.0.1" is the default IPaddress.

    Console.WriteLine("Connected");
    //Console.Write("Enter the string to be transmitted : ");

    while (running)
    {
    Console.Write("Enter the string to be transmitted : ");
    String str = Console.ReadLine();
    String recStr = "";
    Stream stm = tcpclnt.GetStream();

    ASCIIEncoding asen = new ASCIIEncoding();
    byte[] ba = asen.GetBytes(str);
    Console.WriteLine("Transmitting...");

    stm.Write(ba, 0, ba.Length);

    byte[] bb = new byte[100];

    int k = stm.Read(bb, 0, 100);

    for (int i = 0; i < k; i++)
    //Console.Write(Convert.ToChar(bb[i]));
    recStr = recStr + Convert.ToChar(bb[i]);
    Console.WriteLine(recStr);
    stm.Flush();
    bb = null;
    ba = null;

    }

    }

    catch (Exception e) {
    Console.WriteLine("Error..... " + e.StackTrace);
    }
    Console.ReadLine();
    }

    }

    //

    Sorry that I still don't know how to use window form. So hope you guys can help me by guiding me through using non window form.

    Thanks in advance;
    Newbie - Just started learning C# for the past 8 days
    JDomo

  5. #4
    lobo521 is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    57
    Rep Power
    8

    Re: C# - Need Help in code for logging

    Check log4net library.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Logging into vBulletin using cURL
    By Affix in forum PHP Tutorials
    Replies: 22
    Last Post: 10-11-2011, 10:50 AM
  2. Logging and handlers
    By denarced in forum Python
    Replies: 0
    Last Post: 05-05-2011, 10:18 PM
  3. How to redirect a page after logging in?
    By hudbarnett in forum PHP Development
    Replies: 4
    Last Post: 09-07-2010, 06:53 AM
  4. logging username
    By dandoe in forum ionFiles
    Replies: 1
    Last Post: 06-29-2009, 07:07 PM
  5. Logging ?
    By Victor in forum Java Help
    Replies: 5
    Last Post: 07-22-2008, 01:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts