• Post Reply Bookmark Topic Watch Topic
  • New Topic

Log file no longer logging...  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added some code to my servlet to log System.out.println() error messages to my log.txt file:


I checked the log.txt file after a few runs of the servlet, and it contained some output, so I thought all was fine.

I then decided I wanted to empty the log file, so I deleted it from the server, then replaced it with a new (empty) log.txt file - but now the new log.txt file stays empty!

Does anyone know why this is happening? If it is normal, how can I best empty the log.txt file?

Thanks,
James
 
Gert Cuppens
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to deleteyour logfile again and this time don't make another log file. I suppose your logging system will make a new file if it can't find a file with the name it's looking for. But whenever you've made the log file yourself instead leaving it to the logging system to make it, I suppose the logging system is stuck : the file already exists and the owner is not the logging system.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but if the file doesn't exist then I'm pretty sure a FileNotFoundException would be thrown (otherwise, would it ever be thrown?).

But maybe this has something to do with it:

I've tried replacing the log.txt file again, but now it shows me *two* log.txt files. Tried deleting them but they stay there - which suggests that they aren't actually there, but when I try and paste in a new one, it asks me if I want to replace the existing file (to which I say yes, and then it display's three log.txt files!)

Thanks,
James
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a Unix server, never ever remove the file - it is still open as far as the O/S is concerned. Instead, if you want to keep the old one, copy it to a new name and do a "cat /dev/null > log_file_name".
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!