Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i want to write a log file(text file) for each step of my process.
Thanks.
Posted
Comments
Reiss 18-Nov-11 9:02am    
What have you tried and what is the issue you are facing?

Have a look at below Article.

log4net Tutorial
 
Share this answer
 
Comments
Mehdi Gholam 18-Nov-11 9:53am    
The standard, 5'ed
RaviRanjanKr 19-Nov-11 9:24am    
My 5+
RaisKazi 19-Nov-11 10:46am    
Thank you Ravi.
There are lot of utilities available like mentioned log4Net. you can also write your own using EnterpriseLibrary and Reflection. Yes reflection reduces the performance but you can use it to capture Method information as well.

Regards
Rushi
 
Share this answer
 
Comments
RaisKazi 22-Nov-11 2:50am    
Not sure why all answers got 1 Down-Vote. 5ed.
Use my article here : Mini Drop-in Replacement for log4net[^]
 
Share this answer
 
Comments
RaisKazi 18-Nov-11 9:42am    
That's a good Alternate. 5ed. But Log4Net is also useful for logging. :)
Here you go

Five methods to Logging[^](Elmah, Health Monitoring, NLog, Log4Net, Model and Data Layer)
 
Share this answer
 
Comments
RaisKazi 22-Nov-11 2:49am    
Not sure why all answers got 1 Down-Vote. 5ed.
C#
using System.Text;


public string LogPath = "D:\LogFiles\";

public string LogFile = LogPath + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + "_Log" + ".txt";


System.IO.File.AppendAllText(LogFile, "Error in connection." + "\r\n");

System.IO.File.AppendAllText(LogFile, "Connected." + "\r\n");

System.IO.File.AppendAllText(LogFile, "Connection closed." + "\r\n");



just write above line at each step where ever you want to write in log file.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900