Select to view content in your preferred language

AGSRequestConfiguration in 200.x

1344
5
Jump to solution
03-12-2024 04:10 AM
zdtorok
Occasional Contributor

There exists a very useful way to debug requests in 100.x, this:

let config = AGSRequestConfiguration.global()
config.debugLogFileURL = URL(fileURLWithPath: "/tmp/arcgis.md")
config.debugLogRequests = true
config.debugLogIncludeRequestHeaders = true
config.debugLogResponses = true
config.debugLogIncludeResponseHeaders = true
config.debugLogResponseTrimThreshold = 500
config.debugLogIgnoreTiledLayerRequests = true

 Is there an equivalent version in 200.x? I checked the documentation but haven't found anything similar.

0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor

Hi @zdtorok,

Please use ConsoleNetworkLogger in 200.x for request logging. You can use following code at the start of the application.

let logger = ConsoleNetworkLogger(requestOptions: [.method, .body, .headers], responseOptions: [.data, .headers])
logger.startLogging()

 

Also, you can use the NetworkLogger protocol to build your own custom network logger.

Hope this helps!

Regards,

Nimesh

View solution in original post

5 Replies
NimeshJarecha
Esri Regular Contributor

Hi @zdtorok,

Please use ConsoleNetworkLogger in 200.x for request logging. You can use following code at the start of the application.

let logger = ConsoleNetworkLogger(requestOptions: [.method, .body, .headers], responseOptions: [.data, .headers])
logger.startLogging()

 

Also, you can use the NetworkLogger protocol to build your own custom network logger.

Hope this helps!

Regards,

Nimesh

tsroyh
by
Emerging Contributor

Hi Nimesh,

How do you access the logs after that? Can you save them to a file? Are they visible anywhere?

Thank you

0 Kudos
NimeshJarecha
Esri Regular Contributor

Hi @tsroyh,

You can view the logs created by ConsoleNetworkLogger in the Xcode debug console. If you want to save the logs to a file, please create your own logger using the NetworkLogger protocol.

Regards,

 Nimesh

0 Kudos
tsroyh
by
Emerging Contributor

Thanks Nimesh!

Is there another step to attach the logger to the ArcGIS SDK/env/map? Just init of  ConsoleNetworkLogger and `startLogging()` doesn't seem to produce any logs.

Thank you

0 Kudos
NimeshJarecha
Esri Regular Contributor

Please make sure the instance of the  logger  is not getting released. If you have a SwiftUI app then you can do this, 

import ArcGIS
import SwiftUI

@main
struct ExamplesApp: App {
    let logger = ConsoleNetworkLogger(requestOptions: [.method, .body, .headers], responseOptions: [.data, .headers])
    
    init() {
        logger.startLogging()
    }
    
    var body: some SwiftUI.Scene {
        .......
    }
}

 

0 Kudos