Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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?

Solved Go to solution

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?

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: 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?

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.

4 REPLIES 4

Re: 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?

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.

Re: 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?

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.

Re: 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?

New Contributor

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

Highlighted

Re: 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?

#thank_you @Jay SenSharma sir