• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Log file deletion while logging in log4j

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using log4j on linux o.s for logging.

Suppose between two successive debug statements .For example
statement 1 - logger.debug("this is statement 1");
statement 2 - logger.debug("this is statement 2");

and i delete my log file after execution of statement 1 and before execution of statement 2 .. then what will happen on the execution of the secong debug statement ..a new file will be created or exception will be thrown ..

As windows acquire locks over the file being in use but this is not the case with linux.

Thanks in advance ..
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and i delete my log file after execution of statement 1 and before execution of statement 2



In practical scenarios you wouldn't be doing this. Why are you trying this usecase?
 
shailendra sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we have certain scenerios which i need to check for real time system ... hence i need to check this thing to avoid any exception.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you can see, trying to delete the file itself becomes a very OS specific thing:

shailendra sharma wrote:

As windows acquire locks over the file being in use but this is not the case with linux.



and i delete my log file after execution of statement 1 and before execution of statement 2 .. then what will happen on the execution of the secong debug statement ..a new file will be created or exception will be thrown ..



From what i have experienced in log4j, this kind of thing can really lead to all kinds of side effects - to the extent of no more logs being written out to the file unless you restart the logging system.
 
reply
    Bookmark Topic Watch Topic
  • New Topic