<?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: How to Implement Custom Logging in Databricks without Using _jvm Attribute with Spark Connect? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-implement-custom-logging-in-databricks-without-using-jvm/m-p/67105#M33281</link>
    <description>&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; logging&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;logging.&lt;/SPAN&gt;&lt;SPAN&gt;getLogger&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;setLevel&lt;/SPAN&gt;&lt;SPAN&gt;(logging.WARN)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;log &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;"DATABRICKS-LOGGER"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;log.&lt;/SPAN&gt;&lt;SPAN&gt;warning&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Hello"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 23 Apr 2024 18:21:06 GMT</pubDate>
    <dc:creator>arpit</dc:creator>
    <dc:date>2024-04-23T18:21:06Z</dc:date>
    <item>
      <title>How to Implement Custom Logging in Databricks without Using _jvm Attribute with Spark Connect?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-implement-custom-logging-in-databricks-without-using-jvm/m-p/66891#M33219</link>
      <description>&lt;P&gt;Hello Databricks Community,&lt;/P&gt;&lt;P&gt;I am currently working in a Databricks environment and trying to set up custom logging using Log4j in a Python notebook. However, I've run into a problem due to the use of Spark Connect, which does not support the _jvm attribute necessary for accessing Log4j directly.&lt;/P&gt;&lt;P&gt;Here's the code I'm using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
log4j = spark._jvm.org.apache.log4j
logger = log4j.LogManager.getLogger("com.databricks.example")
logger.setLevel(log4j.Level.ERROR)
logger.error("This is a test error message.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Upon executing, I receive the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[JVM_ATTRIBUTE_NOT_SUPPORTED] Attribute `_jvm` is not supported in Spark Connect as it depends on the JVM. If you need to use this attribute, do not use Spark Connect when creating your session.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone suggest an alternative approach for implementing custom logging in a Python notebook on Databricks that complies with the restrictions of Spark Connect? Are there Python-native methods or libraries that integrate well with Databricks for this purpose?&lt;/P&gt;&lt;P&gt;Thank you in advance for your assistance!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 06:56:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-implement-custom-logging-in-databricks-without-using-jvm/m-p/66891#M33219</guid>
      <dc:creator>Olaoye_Somide</dc:creator>
      <dc:date>2024-04-22T06:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Implement Custom Logging in Databricks without Using _jvm Attribute with Spark Connect?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-implement-custom-logging-in-databricks-without-using-jvm/m-p/67105#M33281</link>
      <description>&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; logging&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;logging.&lt;/SPAN&gt;&lt;SPAN&gt;getLogger&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;setLevel&lt;/SPAN&gt;&lt;SPAN&gt;(logging.WARN)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;log &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;"DATABRICKS-LOGGER"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;log.&lt;/SPAN&gt;&lt;SPAN&gt;warning&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Hello"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Apr 2024 18:21:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-implement-custom-logging-in-databricks-without-using-jvm/m-p/67105#M33281</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2024-04-23T18:21:06Z</dc:date>
    </item>
  </channel>
</rss>

