Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

I have accidentally deleted my current hdfs-audit.log file and namenode.log file. How to create a new log files without restarting name node?

avatar
Contributor
 
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Joshva Peter

hdfs-audit and namenode log files are generated via log4j framework. Which is initialized at the time of component startup and creates the log file for writing or use the existing log file for writing in append mode. However if you delete these log files in the running mode of the components then the logging will not be reinitialized hence you will not see the new log file generated. This happens because the log4j appender will has a handle for the deleted file hence it will continue to write to it (which does not exist now because it is deleted), log4j will not detect that it has been deleted.

In custom applications we can make it happen by reinitializing the logging configuration via code, But existing components like NameNode does not control logging initialization/resetConfiguration at the code level.

org.apache.log4j.LogManager.resetConfiguration();

So you will need to restart the affected components (like NameNode in this case) to see the new files getting created.

View solution in original post

4 REPLIES 4

avatar
Master Mentor

@Joshva Peter

hdfs-audit and namenode log files are generated via log4j framework. Which is initialized at the time of component startup and creates the log file for writing or use the existing log file for writing in append mode. However if you delete these log files in the running mode of the components then the logging will not be reinitialized hence you will not see the new log file generated. This happens because the log4j appender will has a handle for the deleted file hence it will continue to write to it (which does not exist now because it is deleted), log4j will not detect that it has been deleted.

In custom applications we can make it happen by reinitializing the logging configuration via code, But existing components like NameNode does not control logging initialization/resetConfiguration at the code level.

org.apache.log4j.LogManager.resetConfiguration();

So you will need to restart the affected components (like NameNode in this case) to see the new files getting created.

avatar
Master Mentor

@Joshva Peter

If this helped answering your query then it will be great if you mark this thread as "Answered" by clicking on the "Accepted" link, that way it will be helpful for HCC users to quickly find the answered threads.

avatar
Contributor

Thanks @Jay SenSharma for your suggestion. It worked fined after the reboot.

avatar

#thank_you @Jay SenSharma sir