def example_network_trace_logging():
    filename = 'log.txt'
    url = 'https://bing.com'
    policies = [UserAgentPolicy('myuseragent'), RedirectPolicy()]
    from azure.core.pipeline.policies import NetworkTraceLoggingPolicy
    import sys
    import logging
    logger = logging.getLogger('azure')
    logger.setLevel(logging.DEBUG)
    handler = logging.StreamHandler(stream=sys.stdout)
    logger.addHandler(handler)
    file_handler = logging.FileHandler(filename)
    logger.addHandler(file_handler)
    logging_policy = NetworkTraceLoggingPolicy()
    logging_policy.enable_http_logger = True
    policies.append(logging_policy)
    client = PipelineClient(base_url=url, policies=policies)
    request = client.get(url)
    pipeline_response = client._pipeline.run(request, logging_enable=True)
    response = pipeline_response.http_response
    assert (response.status_code == 200)
def example_network_trace_logging():
    filename = 'log.txt'
    url = 'https://bing.com'
    policies = [UserAgentPolicy('myuseragent'), RedirectPolicy()]
    from azure.core.pipeline.policies import NetworkTraceLoggingPolicy
    import sys
    import logging
    logger = logging.getLogger('azure')
    logger.setLevel(logging.DEBUG)
    handler = logging.StreamHandler(stream=sys.stdout)
    logger.addHandler(handler)
    file_handler = logging.FileHandler(filename)
    logger.addHandler(file_handler)
    logging_policy = NetworkTraceLoggingPolicy()
    logging_policy.enable_http_logger = True
    policies.append(logging_policy)
    client = PipelineClient(base_url=url, policies=policies)
    request = client.get(url)
    pipeline_response = client._pipeline.run(request, logging_enable=True)
    response = pipeline_response.http_response
    assert (response.status_code == 200)