<?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 configure logging from a custom search command to the search.log Splunk Web using the Splunk Python SDK? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285819#M86478</link>
    <description>&lt;P&gt;Have you actually tried this? I have this line in my code and it's working fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;def generate(self):
...
    self.logger.fatal("This is a test")
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;search.log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Some timestamp] ERROR ScriptRunner - stderr from 'C:\Program Files\Splunk\bin\PYTHON.EXE C:\Program Files\Splunk\etc\apps\[...]\helloworld.py __EXECUTE__ [...]:  This is a test
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 Mar 2016 14:46:18 GMT</pubDate>
    <dc:creator>gwobben</dc:creator>
    <dc:date>2016-03-22T14:46:18Z</dc:date>
    <item>
      <title>How to configure logging from a custom search command to the search.log Splunk Web using the Splunk Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285818#M86477</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm writing a search command and need to log events from it to Splunk Web. I'm using the Python SDK in the current version 1.5.0. I already looked into answer 80712 and could not find any other concerned with logging.&lt;/P&gt;

&lt;P&gt;I'm looking for the correct configuration of the logger already included in the SearchCommand base Class, so that I can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class MySearchCommand(GeneratingCommand):
    def generate(self):
        self.logger.info('my message')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So that 'my message' will be shown in the log after clicking Job -&amp;gt; Inspect Job -&amp;gt; search.log&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;BR /&gt;
Johannes&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 13:15:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285818#M86477</guid>
      <dc:creator>johannesschilli</dc:creator>
      <dc:date>2015-10-21T13:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure logging from a custom search command to the search.log Splunk Web using the Splunk Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285819#M86478</link>
      <description>&lt;P&gt;Have you actually tried this? I have this line in my code and it's working fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;def generate(self):
...
    self.logger.fatal("This is a test")
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;search.log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Some timestamp] ERROR ScriptRunner - stderr from 'C:\Program Files\Splunk\bin\PYTHON.EXE C:\Program Files\Splunk\etc\apps\[...]\helloworld.py __EXECUTE__ [...]:  This is a test
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Mar 2016 14:46:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285819#M86478</guid>
      <dc:creator>gwobben</dc:creator>
      <dc:date>2016-03-22T14:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure logging from a custom search command to the search.log Splunk Web using the Splunk Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285820#M86479</link>
      <description>&lt;P&gt;Your problem may be the default logging level, which is &lt;CODE&gt;ERROR&lt;/CODE&gt;. In order for your &lt;CODE&gt;self.logger.info&lt;/CODE&gt; and &lt;CODE&gt;self.logger.debug&lt;/CODE&gt; invocations to make it to the &lt;CODE&gt;/opt/splunk/var/run/splunk/dispatch/.../search.log&lt;/CODE&gt; of the job, you must either globally reduce the logging level, or reduce it for the appropriate channel (Settings: Server Settings: Server Logging or &lt;CODE&gt;/opt/splunk/etc/log.cfg&lt;/CODE&gt;, &lt;EM&gt;if&lt;/EM&gt; you can identify the pertinent channel---I certainly can't), or issue &lt;CODE&gt;self.logger.logging_level = 'DEBUG'&lt;/CODE&gt; in your command's &lt;CODE&gt;generate&lt;/CODE&gt; method (or equivalent; &lt;CODE&gt;generate&lt;/CODE&gt; is for &lt;CODE&gt;GeneratingCommand&lt;/CODE&gt; subclasses).&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 20:46:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-configure-logging-from-a-custom-search-command-to-the/m-p/285820#M86479</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2018-05-03T20:46:36Z</dc:date>
    </item>
  </channel>
</rss>

