Support Questions

Find answers, ask questions, and share your expertise

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?

Explorer
 
1 ACCEPTED SOLUTION

Super 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

Super 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.

Super 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.

Explorer

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

#thank_you @Jay SenSharma sir

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.