<?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 Querying server logs does not work when filtering on Services in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/querying-server-logs-does-not-work-when-filtering/m-p/1506333#M10354</link>
    <description>&lt;P&gt;I'm creating a process where I can query the server logs for activity on certain feature services.&amp;nbsp; The code loops through the services on a server and tries to use the LogManager.query function to query the logs with a filter on a specific service name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcgis.gis.admin
import pandas as pd

gis = GIS(url, username, password, verify_cert=False)

gis_servers = gis.admin.servers.list()

#To list all services
for server in gis_servers:
    # Create the LogManager object on the server to get the logs
    log_manager = server.logs
    folders = [f for f in server.services.folders if f.lower() != "system"]
    for folder in folders:
        for service in server.services.list(folder=folder):
            
            service_name = service.properties.serviceName

            log_query = log_manager.query(start_time=None,
            end_time=None, 
            since_server_start=False, 
            level='VERBOSE', 
            services=service_name, 
            machines='*', 
            server='*', 
            codes=None, 
            process_IDs=None, 
            export=False, 
            export_type='CSV', 
            out_path=None, 
            max_records_return=10)
            print(pd.DataFrame.from_records(log_query))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But whenever I run the code above, I get the first ten results from all of the server logs with no filter on services.&amp;nbsp; I have tried running it with the following formats for the service_name variable (this is entered as a string):&lt;/P&gt;&lt;P&gt;[ServiceName]&lt;/P&gt;&lt;P&gt;[ServiceName].MapServer&lt;/P&gt;&lt;P&gt;[FolderName].[ServiceName].MapServer&lt;/P&gt;&lt;P&gt;I get the same results every time.&lt;/P&gt;&lt;P&gt;Is there something I should be doing differently when trying to filter using the LogManager.query function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jul 2024 20:30:57 GMT</pubDate>
    <dc:creator>epugliano</dc:creator>
    <dc:date>2024-07-17T20:30:57Z</dc:date>
    <item>
      <title>Querying server logs does not work when filtering on Services</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/querying-server-logs-does-not-work-when-filtering/m-p/1506333#M10354</link>
      <description>&lt;P&gt;I'm creating a process where I can query the server logs for activity on certain feature services.&amp;nbsp; The code loops through the services on a server and tries to use the LogManager.query function to query the logs with a filter on a specific service name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcgis.gis.admin
import pandas as pd

gis = GIS(url, username, password, verify_cert=False)

gis_servers = gis.admin.servers.list()

#To list all services
for server in gis_servers:
    # Create the LogManager object on the server to get the logs
    log_manager = server.logs
    folders = [f for f in server.services.folders if f.lower() != "system"]
    for folder in folders:
        for service in server.services.list(folder=folder):
            
            service_name = service.properties.serviceName

            log_query = log_manager.query(start_time=None,
            end_time=None, 
            since_server_start=False, 
            level='VERBOSE', 
            services=service_name, 
            machines='*', 
            server='*', 
            codes=None, 
            process_IDs=None, 
            export=False, 
            export_type='CSV', 
            out_path=None, 
            max_records_return=10)
            print(pd.DataFrame.from_records(log_query))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But whenever I run the code above, I get the first ten results from all of the server logs with no filter on services.&amp;nbsp; I have tried running it with the following formats for the service_name variable (this is entered as a string):&lt;/P&gt;&lt;P&gt;[ServiceName]&lt;/P&gt;&lt;P&gt;[ServiceName].MapServer&lt;/P&gt;&lt;P&gt;[FolderName].[ServiceName].MapServer&lt;/P&gt;&lt;P&gt;I get the same results every time.&lt;/P&gt;&lt;P&gt;Is there something I should be doing differently when trying to filter using the LogManager.query function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 20:30:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/querying-server-logs-does-not-work-when-filtering/m-p/1506333#M10354</guid>
      <dc:creator>epugliano</dc:creator>
      <dc:date>2024-07-17T20:30:57Z</dc:date>
    </item>
  </channel>
</rss>

