Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do logging in C# without using 3rd party libraries? [closed]

I would like to implement logging in my application, but would rather not use any outside frameworks like log4net.

So I would like to do something like DOS's echo to a file. What is the most effective way to do it?

Is there a way to log unhandled exceptions logged without using an outside framework?

like image 562
IAdapter Avatar asked Feb 20 '11 14:02

IAdapter


People also ask

What is logging in C?

C log() PrototypeThe log() function takes a single argument and returns a value of type float . [Mathematics] logex = log(x) [In C programming] It is defined in <math. h> header file. In order to find the log() of long double or float numbers, you can use the following prototype.

What is a logging in programming?

A log, in a computing context, is the automatically produced and time-stamped documentation of events relevant to a particular system. Virtually all software applications and systems produce log files.


1 Answers

public void Logger(string lines) {   //Write the string to a file.append mode is enabled so that the log   //lines get appended to  test.txt than wiping content and writing the log    using(System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt", true))   {     file.WriteLine(lines);   } } 

For more information MSDN

like image 168
Brandon Avatar answered Sep 23 '22 16:09

Brandon