<?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: Unable to create log files using logging.basicConfig() in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122314#M46739</link>
    <description>&lt;P&gt;This is working Fine. But do you know how can we generate different log files for different runs?&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jun 2025 06:39:34 GMT</pubDate>
    <dc:creator>HariPrasad1</dc:creator>
    <dc:date>2025-06-20T06:39:34Z</dc:date>
    <item>
      <title>Unable to create log files using logging.basicConfig()</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122261#M46717</link>
      <description>&lt;P&gt;When I run this code below, I am not able to see the file under the path specified:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; logging&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; logging.&lt;/SPAN&gt;&lt;SPAN&gt;getLogger&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;__name__&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logging.&lt;/SPAN&gt;&lt;SPAN&gt;basicConfig&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;filename&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'/Volumes/d_use1_ach_dbw_databricks1/default/ach_elegibility_raw/logs/example.log'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;encoding&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'utf-8'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;level&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;logging.DEBUG)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;debug&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'This message should go to the log file'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;info&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'So should this'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;warning&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'And this, too'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;logger.&lt;/SPAN&gt;&lt;SPAN&gt;error&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'And non-ASCII stuff, too, like Øresund and Malmö'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;How do we locate the file in this scenario?&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Jun 2025 14:29:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122261#M46717</guid>
      <dc:creator>HariPrasad1</dc:creator>
      <dc:date>2025-06-19T14:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to create log files using logging.basicConfig()</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122275#M46725</link>
      <description>&lt;P&gt;The issue is happening because you're calling logging.getLogger(__name__) before setting up logging.basicConfig(). When the logger is created too early, it doesn't know about the file handler, so it doesn't write to the file.&lt;/P&gt;&lt;P&gt;To fix this, make sure you configure logging before creating or using the logger. Here's the corrected version:&lt;/P&gt;&lt;P&gt;------------------------------------&lt;BR /&gt;import logging&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;# Make sure the log directory exists&lt;BR /&gt;os.makedirs('/Volumes/d_use1_ach_dbw_databricks1/default/ach_elegibility_raw/logs/', exist_ok=True)&lt;/P&gt;&lt;P&gt;# Configure logging first&lt;BR /&gt;logging.basicConfig(&lt;BR /&gt;filename='/Volumes/d_use1_ach_dbw_databricks1/default/ach_elegibility_raw/logs/example.log',&lt;BR /&gt;encoding='utf-8',&lt;BR /&gt;level=logging.DEBUG,&lt;BR /&gt;format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;# Now get the logger&lt;BR /&gt;logger = logging.getLogger(__name__)&lt;/P&gt;&lt;P&gt;# Log messages&lt;BR /&gt;logger.debug('This message should go to the log file')&lt;BR /&gt;logger.info('So should this')&lt;BR /&gt;logger.warning('And this, too')&lt;BR /&gt;logger.error('And non-ASCII stuff, too, like Øresund and Malmö')&lt;BR /&gt;Also, if you're running this inside Databricks, local file paths like /Volumes/... might not work. In that case, update the file path to:&lt;/P&gt;&lt;P&gt;------------------------------------------------&lt;BR /&gt;/dbfs/Volumes/d_use1_ach_dbw_databricks1/default/ach_elegibility_raw/logs/example.log&lt;BR /&gt;Then you can view the log file using:&lt;/P&gt;&lt;P&gt;----------------------------&lt;BR /&gt;%fs head /Volumes/d_use1_ach_dbw_databricks1/default/ach_elegibility_raw/logs/example.log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 16:44:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122275#M46725</guid>
      <dc:creator>Yogesh_Verma_</dc:creator>
      <dc:date>2025-06-19T16:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to create log files using logging.basicConfig()</title>
      <link>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122314#M46739</link>
      <description>&lt;P&gt;This is working Fine. But do you know how can we generate different log files for different runs?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jun 2025 06:39:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/unable-to-create-log-files-using-logging-basicconfig/m-p/122314#M46739</guid>
      <dc:creator>HariPrasad1</dc:creator>
      <dc:date>2025-06-20T06:39:34Z</dc:date>
    </item>
  </channel>
</rss>

