<?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 After adding logging statements into Python script and running it via Splunk CLI, why are there no log messages in python.log? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209918#M2793</link>
    <description>&lt;P&gt;I'm trying to debug a Python script and in doing so placed some logging statements into the script.&lt;/P&gt;

&lt;P&gt;Following these posts for the basics:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/80712/logging-from-python-in-splunk.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;Logging from Python in Splunk&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/85795/python-logging-in-splunk.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;Python logging in splunk&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm going off the simple statement here&lt;BR /&gt;
"You can also just call logging directly and your logs will appear in python.log:"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; logging.warning("Something bad happened: %s", "out of memory")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so my code looks just like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import logging
logging.info("message here")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running it using the Splunk CLI command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; splunk cmd python ./confcheck_correlation_searches.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And yet still nothing in python.log. Any ideas what I'm missing here?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Dec 2015 14:12:24 GMT</pubDate>
    <dc:creator>ConnorG</dc:creator>
    <dc:date>2015-12-29T14:12:24Z</dc:date>
    <item>
      <title>After adding logging statements into Python script and running it via Splunk CLI, why are there no log messages in python.log?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209918#M2793</link>
      <description>&lt;P&gt;I'm trying to debug a Python script and in doing so placed some logging statements into the script.&lt;/P&gt;

&lt;P&gt;Following these posts for the basics:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/80712/logging-from-python-in-splunk.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;Logging from Python in Splunk&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/85795/python-logging-in-splunk.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;Python logging in splunk&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm going off the simple statement here&lt;BR /&gt;
"You can also just call logging directly and your logs will appear in python.log:"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; logging.warning("Something bad happened: %s", "out of memory")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so my code looks just like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import logging
logging.info("message here")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running it using the Splunk CLI command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; splunk cmd python ./confcheck_correlation_searches.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And yet still nothing in python.log. Any ideas what I'm missing here?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 14:12:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209918#M2793</guid>
      <dc:creator>ConnorG</dc:creator>
      <dc:date>2015-12-29T14:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: After adding logging statements into Python script and running it via Splunk CLI, why are there no log messages in python.log?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209919#M2794</link>
      <description>&lt;P&gt;The first link you showed has the answer wrapped up in a function.  Here it is without being wrapped into a function:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# create logger object for logging - see &lt;A href="https://docs.python.org/2/howto/logging.html" target="test_blank"&gt;https://docs.python.org/2/howto/logging.html&lt;/A&gt; for details
import logging
logger = logging.getLogger('confcheck_correlation_searches.py')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler('/var/log/splunk/confcheck_correlation_searches.log')
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s | src="%(name)s" | lvl="%(levelname)s" | msg="%(message)s"')
fh.setFormatter(formatter)
logger.addHandler(fh)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note, you may wish to change the formatter... i just grabbed the first example I had.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 14:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209919#M2794</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-12-29T14:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: After adding logging statements into Python script and running it via Splunk CLI, why are there no log messages in python.log?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209920#M2795</link>
      <description>&lt;P&gt;Yes I noticed this, but if you read further down it also states that &lt;/P&gt;

&lt;P&gt;"You can also just call logging directly and your logs will appear in python.log"&lt;/P&gt;

&lt;P&gt;As I followed in my example.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 16:50:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/After-adding-logging-statements-into-Python-script-and-running/m-p/209920#M2795</guid>
      <dc:creator>ConnorG</dc:creator>
      <dc:date>2015-12-29T16:50:08Z</dc:date>
    </item>
  </channel>
</rss>

