<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loguru doesn't save logs to Databricks volume in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117506#M45512</link>
    <description>&lt;P&gt;I am having the same problem. I am using a work-around currently but definitely would love to see a solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI: here is my work-around:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;add&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;output_folder_path&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/../logging/workflow_job1_&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;datetime_str&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.log"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;rotation&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'10 days'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;retention&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"10 days"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;level&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"DEBUG"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 02 May 2025 12:15:29 GMT</pubDate>
    <dc:creator>Thomas_Zhang</dc:creator>
    <dc:date>2025-05-02T12:15:29Z</dc:date>
    <item>
      <title>Loguru doesn't save logs to Databricks volume</title>
      <link>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117498#M45509</link>
      <description>&lt;P&gt;I've added an external volume named "logs" to my Databricks Unity Catalog. Within a Databricks notebook I can verify that it exists (os.path.exists(path='/Volumes/my_catalog/schema_name/logs') and even write a file to it that I can see within the Databricks UI using the following syntax:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with open('/Volumes/my_catalog/schema_name/logs/test_file.txt', 'w') as file:
    file.write('my test')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I try to use loguru to write logs to the volume they don't appear within the volume. I've used the following syntax:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from datetime import datetime
import os

from loguru import logger

LOGS_FOLDER_PATH = '/Volumes/my_catalog/schema_name/logs/'
DATE_TIME_STRING = datetime.now().strftime('%Y-%m-%d__%H_%M_%S')

file_handler_path = LOGS_FOLDER_PATH + DATE_TIME_STRING + '.log'

logger.add(file_handler_path)
logger.info((f'Logging is set up including the file handler that saves the logs to the '
f'following destination: {file_handler_path}'))
logger.error('an error has happened')
logger.warning('my warning')
logger.info('my info')&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;The first logger.info statement returns the following path as the destination: /Volumes/my_catalog/schema_name/logs/2025-04-30__10_01_24.log&lt;/P&gt;&lt;P&gt;But within the Databricks UI I can't see a log file! os.listdir(path='/Volumes/my_catalog/schema_name/logs') tells me that the file exists but after restarting my cluster it tells me the file does not exist any more (so probably it has never existed at all).&lt;/P&gt;&lt;P&gt;When I add a folder to the path of the file handler (e. g. " /Volumes/my_catalog/schema_name/logs/additional_folder/2025-04-30__10_01_24.log" instead of " /Volumes/my_catalog/schema_name/logs/2025-04-30__10_01_24.log") the folder "additional_folder" is actually created within the external volume "logs" but still the log file is not created. So, this shows that loguru actually does something and has access to the external volume.&lt;/P&gt;&lt;P&gt;Within another Databricks project I've used to same syntax but the file handler path was a mounted Azure blob storage. In this project saving the logs worked. So, I guess that the problem is somewhere within the external volume that I added within the Databricks unity catalog...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 11:31:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117498#M45509</guid>
      <dc:creator>Johannes_E</dc:creator>
      <dc:date>2025-05-02T11:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loguru doesn't save logs to Databricks volume</title>
      <link>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117506#M45512</link>
      <description>&lt;P&gt;I am having the same problem. I am using a work-around currently but definitely would love to see a solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI: here is my work-around:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;add&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;output_folder_path&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/../logging/workflow_job1_&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;datetime_str&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.log"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;rotation&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'10 days'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;retention&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"10 days"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;level&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"DEBUG"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 02 May 2025 12:15:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117506#M45512</guid>
      <dc:creator>Thomas_Zhang</dc:creator>
      <dc:date>2025-05-02T12:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Loguru doesn't save logs to Databricks volume</title>
      <link>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117543#M45523</link>
      <description>&lt;P&gt;Unfortunately, your workaround does not work in my case &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 17:47:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/loguru-doesn-t-save-logs-to-databricks-volume/m-p/117543#M45523</guid>
      <dc:creator>Johannes_E</dc:creator>
      <dc:date>2025-05-02T17:47:53Z</dc:date>
    </item>
  </channel>
</rss>

