We have a very simple ASP.Net page for uploading a file to our web server. There are no controls on the page - the client uses it to automatically send us a file every night.
Sometimes the file seems inaccessible to us, but the client reports that he sent it.
We added some registration statements to the page and found something rather strange. The page stops running in the middle of the log statement. There are no exceptions, just up and dying.
Here is the code:
protected void Page_Load(object sender, EventArgs e) {
try {
log.Debug("Update Inventory page requested through HTTP {2} on {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), IsPostBack ? "POST" : "GET");
string basePath = Server.MapPath("~/admin/uploads/");
log.Debug("Saving to folder {0}", basePath);
if (!Directory.Exists(basePath)) {
log.Debug("Creating folder {0}", basePath);
Directory.CreateDirectory(basePath);
}
string fileName = DateTime.Now.Ticks.ToString() + ".dat";
string path = basePath + fileName;
log.Debug("Filename to save is {0}", fileName);
StreamReader reader = new StreamReader(stream);
string fileContents = reader.ReadToEnd();
log.Debug("File received by GET is " + fileContents.Length + " characters long and begins with: "
+ Environment.NewLine + fileContents.Substring(0, Math.Min(fileContents.Length, 1000)));
File.WriteAllText(path, fileContents);
log.Debug("Update Inventory page processing finished.");
}
catch (Exception ex) {
log.Debug(ex);
}
}
Processing seems to die in the middle of a log statement that prints the length and first part of the fileContents variable. Logging that occurs when a process crashes is as follows:
2010-08-02 02:46:01.7342|DEBUG|UpdateInventory|Update Inventory page requested through HTTP GET on 8/2/2010 2:46:01 AM
2010-08-02 02:46:01.7655|DEBUG|UpdateInventory|Saving to folder c:\hosting\sites\musicgoround.com\wwwroot\admin\uploads\
2010-08-02 02:46:01.7811|DEBUG|UpdateInventory|Filename to save is 634163139617811250.dat
2010-08-02 02:48:02.3905|DEBUG|UpdateInventory|
I really don’t understand what to do with it.
, , reader.ReadToEnd(). , , , ( - ).
try-catch. NLog - , , , Simple Logging Facade Codeplex. , , - , , , .
, ? , , ?
, , , , - NLog, - .