# How to clean the folder of Slicer\_Logs?

**URL:** <https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193>\
**Category:** Support\
**Created:** [November 18, 2019, 3:07pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193 "2019-11-18T15:07:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [November 18, 2019, 3:07pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/1 "2019-11-18T15:07:23Z")

</div>

Operating system: Windows  
Slicer version: 4.11.0-2019  
Expected behavior: Keep Slicer\_Logs folder as small as possible  
Actual behavior: it is swelling after each usage

Hi All expertise in Slicer:  
I happened to see my C: drive space shrunk and then figure it out that users\Documents\Slicer\_Logs folder having lots of history of my slicer usage.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/f/4f61a811c803289e7c62de29bc94c10829ea6f0d.png)

So how to keep it as small as possible? Is there any python/CLI functions so that I may clean it before or after each time usage?

Thanks a lot, Aiden

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [November 18, 2019, 3:37pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/2 "2019-11-18T15:37:35Z")

</div>

I’m not familiar with this “Slicer\_Logs” directory within Documents. Did you go into Settings-\>Modules and change “Temporary Directory” from the default location of %LocalAppData%/Temp/Slicer ? This is where Slicer logs are typically found and are usually fairly small in size.

Did you change Settings-\>Cache which also has a default location of %LocalAppData%/Temp/Slicer/RemoteIO to be in “Slicer\_Logs” and then increase the max cache size really large as well? Log files wouldn’t result in such a large file usage, but some cache location could grow large if you set the limit to something really high.

Or by chance have you been writing custom code or using a third party Slicer extension that is using this “Slicer\_Logs” location?

---

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [November 18, 2019, 3:43pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/3 "2019-11-18T15:43:09Z")

</div>

Thanks a lot for your quick reply, James.

I guess I did not use a third party slicer extension associated with Slicer\_Logs (or, LOL, I do not know it at all).

Yes, I did set up the “Temporary directory” as “C:/Users/Aiden.Zhu/documents/Slicer\_Logs”. But it seems I did not really set up a large Cache, here is my settings:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/6/363dc52a15540fc9346a27e9dc4da5e5b4fe8d66.png)

So is there any command I may use to clean cache?  
Thanks again.  
Aiden

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 18, 2019, 4:06pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/4 "2019-11-18T16:06:13Z")

</div>

Only the last 10 log files are kept by default (you can change the value in your Slicer-NNN.ini file in LogFiles section “NumberOfFilesToKeep” value), but usually the files are small, so it should not be an issue.

Maybe you have enabled “Developer mode”. In developer mode, CLI module input and output files are not deleted after execution to make debugging easier. You can disable developer mode if this causes an issue for you.

---

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [November 18, 2019, 4:41pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/5 "2019-11-18T16:41:14Z")

</div>

@lassoan@jamesobutler  
Thanks a lot.  
Yeah, I guess it’s just due to my “Developer Mode” on. Then all right for me, I just need pay attention to it to make sure of that I have enough space in C-drive.

Best, Aiden

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [October 31, 2025, 5:33am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/6 "2025-10-31T05:33:48Z")

</div>

Can I know where the log files go in linux systems?  
Can I also get some resources to implement logging in my extension?  
How can I inspect core slicer’s logging system?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 31, 2025, 2:48pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/7 "2025-10-31T14:48:28Z")

</div>

> [@Victor\_Wayne](#):
>
> Can I know where the log files go in linux systems?

Current application log:

```
slicer.app.errorLogModel().filePath

```

Recent log file paths:

```
slicer.app.recentLogFiles()

```

> [@Victor\_Wayne](#):
>
> Can I also get some resources to implement logging in my extension?

You can use standard Python, VTK, ITK, Qt, console logging - they are all captured in the application log.

> [@Victor\_Wayne](#):
>
> How can I inspect core slicer’s logging system?

You can access all the logs, connect event handlers, etc. through the [`slicer.app.errorLogModel()` object](https://github.com/commontk/CTK/blob/master/Libs/Core/ctkErrorLogAbstractModel.h).

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [November 3, 2025, 8:35am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/8 "2025-11-03T08:35:42Z")

</div>

Ok I get it.

How can I set the number of files that is kept in the log folder? I want to keep all the log files.  
If I can’t keep all the log files, what is the maximum number of files I can keep? I don’t want to be limited to only ten. (it seems only 10 files get stored according to the experiment I did.) If I can keep the number of files that can be kept in the log folder, How can I set the number of files to keep programmatically? should I put it in the .slicerrc.py file?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 3, 2025, 9:26am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/9 "2025-11-03T09:26:50Z")

</div>

This number is stored in the application settings. I didn’t find it in the GUI, but you can open the `Slicer.ini` file and change the number for the `NumberOfFilesToKeep` entry. I don’t think there is a maximum.

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [November 10, 2025, 4:57am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/10 "2025-11-10T04:57:56Z")

</div>

How can I keep all the log files? the log files goes inside the tmp directory and if I just reboot my or shut down and boot it the next day the whole directory is gone. how can I prevent this? Is there any way to change the cmake files so that the logs goes in the folder where the slicer executable lives? I changed the number of files to keep to 10,000 I need all the log files.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 10, 2025, 5:10am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/11 "2025-11-10T05:10:39Z")

</div>

> [@Victor\_Wayne](#):
>
> How can I keep all the log files?

Why do you need to keep all the log files? How many Slicer sessions are you starting and ending a day? If you explain your use case, we might be able to give more pointed advise.

If you are on Linux you might simply add a cronjob to rsync the files to a permanent location (say every 5 minutes).

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [November 10, 2025, 6:22am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/12 "2025-11-10T06:22:00Z")

</div>

We need to collect all the details from our custom built slicer such as which functionality the user is using the most; how are they navigating through our modified custom built slicer; what series of operation that led to the crash if at all there is one and how much time user spends working on our components and much more. We also don’t want to make such that their tmp is constantly sending us their log files. We should be able to ssh into their machine and look around the log files if there is a problem. This is our use case. We at least need 1000 log files in a path where it doesn’t get automatically cleaned.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 10, 2025, 6:55am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/13 "2025-11-10T06:55:03Z")

</div>

> [@Victor\_Wayne](#):
>
> custom built slicer

If you have a custom built slicer, I am pretty sure you can control where the files are written?

I do not know where they are in the source code, but a quick github repo search for logfile keyword, returned results both of to your inquiries (e.g., how many log files to keep, as well as their location). It looks like it is

[Base/QTGUI/qSlicerApplication.cxx](https://github.com/Slicer/Slicer/blob/071e13bf55808ae4a65d06940a60ddbcf231b9cf/Base/QTGUI/qSlicerApplication.cxx#L996) you want to modify

`https://github.com/search?q=repo%3ASlicer%2FSlicer+logfile&type=code`

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [November 10, 2025, 8:36am UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/14 "2025-11-10T08:36:11Z")

</div>

Is there any way to change the path using the .ini files where all the configuration goes? I don’t want to modify the core slicer’s code.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 10, 2025, 12:36pm UTC](https://discourse.slicer.org/t/how-to-clean-the-folder-of-slicer-logs/9193/15 "2025-11-10T12:36:52Z")

</div>

You may want to have a look at the [SlicerTelemetry](https://github.com/Slicer/SlicerTelemetry) extension to get more specific info about what features are being used and how often. Be sure to get user consent before collecting this data.

> [@Victor\_Wayne](#):
>
> I don’t want to modify the core slicer’s code.

While it wouldn’t be as clean, you could add custom python code to copy the log file somewhere either with a timer or at application exit (or both).
