Windows is notorious for filling up the storage. Many temporary files are generated regularly, in order to decrease the loading time and improve performance in general. However, there are times when things go wrong and a multitude of errors show up in Windows.
Windows 10 keeps a log of the errors in the Event log, which can be accessed by the users to extract the error code and perform the appropriate troubleshooting steps. This event log can end up saving a lot of information, which can result in your PC running out of space.
Here I shall discuss what is the default event viewer path, and How to delete win log files in Windows 10 including PowerShell clear all event logs.
Where Are Windows Log Files Stored In Windows 10?
Before cleaning up Windows log files, you may be wondering what the event viewer default path is, and where are the Windows 10 event logs stored on our computers. This is an important piece of information that may come useful while troubleshooting your computer or clearing Windows log files.
There are two folders, depending on your Windows version where you may find the Windows log files. First, look in the following folder:
%windir%\System32\Winevt\Logs\
However, you may not find this folder on certain, in which case you can look under the following folder:
%windir%\System32\config\
Note: %windir% is your computer’s OS directory.
How To Delete Win Log Files In Windows 10?
While Windows 10 tries to free up space automatically, the Event Viewer fails most of the time in clearing the data automatically. In such cases, you will need to clear event log in Windows 10 manually. There are several ways to delete log files in Windows 10.
Method 1: Use Command Prompt
The command prompt is the Windows command-line utility tool, which can be used to perform any task in Windows with command lines. You can also use the command prompt to clear event viewer in Windows 10. You can use the command prompt to clear individual log files, or clear entire event log in Windows 10.
Here are the steps that you can follow to delete all Windows log files:
- Open an elevated command prompt. You can do so from the Windows search context menu, or from a Run dialog (use Ctrl + Shift + Enter to launch cmd with admin privileges).
- Next, go the event viewer default path that is mentioned above using the change directory command:
cd %windir%\system32\config - To clear all the win log files, type the following command and press Enter:
del *.log /a /s /q /f
All files with a .log extension will be deleted from your computer.
If you wish to clear individual log files, here are the commands that you need to enter:
- Open another admin command prompt.
- To list the log files, type the following command and press Enter:
wevtutil el
- From the list that appears, if you find a certain log file that you wish to delete, type the following command and press Enter:
wevtutil cl <name of the log>
This will delete that particular log from the Event Viewer file.
Method 2: Make A Command File To Automatically Clear Log Files
When you are trying new experimental features, there is a chance that you may be generating a lot of win log files on your computer if the feature crashes. In such cases, you might be wondering how to delete win log files in Windows 10 automatically.
You can make a command file (.cmd) to automate this process. Follow these steps to create this command file:
- Open a text editor like Notepad or MS visual code.
- Type the following code, or copy and paste the following in the editor:
@echo off
FOR /F “tokens=1,2*” %%V IN (‘bcdedit’) DO SET adminTest=%%V
IF (%adminTest%)==(Access) goto noAdmin
for /F “tokens=*” %%G in (‘wevtutil.exe el’) DO (call :do_clear “%%G”)
echo.
echo Event Logs have been cleared! ^<press any key^>
goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
echo You must run this script as an Administrator!
echo ^<press any key^>
:theEnd
pause>NUL
- Save the name of this command with the extension .cmd in any location that you prefer.
- Next, run this command file as administrator, by choosing the correct option from the right-click context menu.
You will see a command prompt window opens, and all the log files are cleared automatically.
Note: Run this file as admin to clear event log files.
Method 3: Use The Event Viewer GUI
In Windows 10, the Event Viewer GUI is polished and very easy to navigate through the settings. If you do not wish to work with command-line tools, you can use the GUI to delete win log files in Windows 10. Follow these steps to launch the event viewer, and clear event log in Windows 10:
- Open a Run dialog.
- Type eventvwr.msc and press Ctrl + Shift + Enter to launch the Event Viewer with admin rights.
- From the leftmost pane, expand the folders by clicking on the small arrow next to the folder.
- In the list of entries, select the entry from the middle pane and click on Clear Log… from Action section in the rightmost pane.
Pro Tip: You can use the Shift key to select a range of entries in the middle pane. - Repeat this for all the entries that you wish to delete.
While this may seem a long process, this is much simpler to navigate through, and you will be done deleting log files in Windows 10.
Method 4: Use PowerShell Clear All Event Logs
PowerShell is a much more powerful command-line tool, and you can use a single command to delete log files in Windows 10. Simply follow these steps:
- Open PowerShell as an admin. You can do this from the start menu, or from the WinX menu if you haven’t replaced PowerShell with CMD in Windows 10.
- Type the following command and press Enter:
wevtutil el | Foreach-Object {wevtutil cl “$_”}
This will clear all the event logs in Windows 10.
Note: This command needs to be run with admin PowerShell.
Method 5: Use Third Party Applications
There are many third party cleaner applications, which can be used to clear temporary files and other junk files in Windows 10. You can use such third-party applications to clean up the event log files.
One of the most popular applications is CCleaner, which can be used to clean all junk files on your computer for free.
If you want a more powerful file deletion software, you can look for premium options like BitRaser For File and its alternatives.
Wrapping Up
So, there you have it. Now you know where the event log directory is and how to delete win log files in Windows 10 using the methods provided above. Comment below if you found this useful, and to discuss further the same.
All the tricks are working fine except the first one. Because I tried all the tricks with different systems and all the tricks are 100% working. Thank you.
Using PowerShell to clear the log files is the best process I think.