title: No Logging on Azure DevOps Pipeline
body: <p>Update:</p>
  <p>Is it possible to add or change a command that executes a pipeline on Azure DevOps?</p>
  <hr />
  <p>Running my program locally on <strong>Visual Studio Code</strong>, I do get outputs.</p>
  <p>However, running my <strong>GitHub</strong> origin branch on <strong>Azure DevOps</strong> does not yield any output.</p>
  <p>I followed a Stack Overflow <a href="https://stackoverflow.com/a/57896847/16105404">answer</a>, which references this solution to a <a href="https://github.com/Azure/azure-functions-python-worker/issues/248#issuecomment-890332588" rel="noreferrer">GitHub Issue</a>.</p>
  <p>I have implemented the below, but Azure's <strong>Raw Logs</strong> return blank on my Python <code>logging</code>.</p>
  <p><code>test_logging.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import logging
  
  filename = &quot;my.log&quot;
  
  global logger
  logger = logging.getLogger()
  logger.setLevel(logging.INFO)
  formatter = logging.Formatter(&quot;%(asctime)s - %(name)s - %(levelname)s - %(message)s&quot;)
  open(filename, &quot;w&quot;).close()  # empty logs
  fileHandler = logging.FileHandler(filename)
  fileHandler.setFormatter(formatter)
  fileHandler.setLevel(logging.INFO)
  logger.addHandler(fileHandler)
  
  logger.error('TEST')
  
  # fetch logs
  with open(filename, &quot;r&quot;) as fileHandler:
      logs = [log.rstrip() for log in fileHandler.readlines()]
  open(filename, &quot;w&quot;).close()  # empty logs
  print('logs = ', logs)
  </code></pre>
  <pre><code>&gt;&gt;&gt; logs = []
  </code></pre>
  <p><code>host.json</code>:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;version&quot;:  &quot;2.0&quot;,
    &quot;logging&quot;: {
      &quot;fileLoggingMode&quot;: &quot;always&quot;,
      &quot;logLevel&quot;: {
        &quot;default&quot;: &quot;Debug&quot;
      }
    } 
  }
  </code></pre>
  <hr />
  <p>I then tried this alternative <code>host.json</code> from <a href="https://stackoverflow.com/q/57648109/16105404">post</a>:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;logging&quot;: {
      &quot;fileLoggingMode&quot;: &quot;debugOnly&quot;,
      &quot;logLevel&quot;: {
          &quot;default&quot;: &quot;None&quot;,
          &quot;Host.Results&quot;: &quot;Information&quot;,
          &quot;Function&quot;: &quot;Information&quot;,
          &quot;Host.Aggregator&quot;: &quot;Information&quot;
      },
      &quot;applicationInsights&quot;: {
          &quot;samplingSettings&quot;: {
              &quot;isEnabled&quot;: false,
              &quot;maxTelemetryItemsPerSecond&quot;: 5
          }
      }
  }
  </code></pre>
  <p><code>azure-pipeline-ontology_tagger.yaml</code></p>
  <pre class="lang-json prettyprint-override"><code># ##########
  # A build run against multiple Python targets
  # ##########
  
  resources:
  - repo: self
  
  variables:
    tag: '$(Build.SourceBranchName)-$(Build.BuildNumber)'
    imageName: '$(Build.Repository.Name)-ontology_tagger'
    artifactFeed: grandproject/private-sources
    repositoryUrl: private-sources
    packageDirectory: workers/ontology_tagger
  
  trigger:
    batch: true
    branches:
      include:
      - master
      - development
      - releases/*
    paths:
      include:
      - &quot;workers/ontology_tagger&quot;
      exclude:
      - &quot;workers&quot;
      - &quot;*.md&quot;
  pr:
    branches:
      include:
      - master
      - development
      - releases/*
    paths:
      include:
      - &quot;workers/ontology_tagger&quot;
      exclude:
      - &quot;workers&quot;
      - &quot;*.md&quot;
  
  stages:
  - stage: BuildWP
    displayName: Build Workers python package
    jobs:
  
    - job: Build
      displayName: Build Worker python image
  
      pool:
        name: EKS-grandproject-dev
  
      steps:
      - bash: env
  
      - task: PipAuthenticate@0
        displayName: Authenticate with artifact feed
        inputs:
          artifactFeeds: $(artifactFeed)
  
      - task: TwineAuthenticate@1
        displayName: Authenticate with artifact feed
        inputs:
          artifactFeed: $(artifactFeed)
  
      - bash: echo &quot;##vso[task.setvariable variable=POETRY_HTTP_BASIC_AZURE_PASSWORD;isOutput=true]$(echo $PIP_EXTRA_INDEX_URL | sed -r 's|https://(.+):(.+)@.*|\2|')&quot;
        name: &quot;PIPAUTH&quot;
  
      - task: Bash@3
        displayName: Test worker
        inputs:
          targetType: 'inline'
          workingDirectory: '$(packageDirectory)'
          script: |
            docker build . --progress plain --pull --target test \
            --build-arg POETRY_HTTP_BASIC_AZURE_PASSWORD=${PIPAUTH_POETRY_HTTP_BASIC_AZURE_PASSWORD} \
            --build-arg ATLASSIAN_TOKEN=$(ATLASSIAN_TOKEN)
      - task: Bash@3
        displayName: Build and publish package
        inputs:
          targetType: 'inline'
          workingDirectory: '$(packageDirectory)'
          script: |
            set -e
            cp $(PYPIRC_PATH) ./
            docker build . --target package --progress plain  --build-arg REPO=$(repositoryUrl)
      - task: Bash@3
        displayName: Build docker image
        inputs:
          targetType: 'inline'
          workingDirectory: '$(packageDirectory)'
          script: |
            docker build . --tag '$(imageName):$(tag)' --progress plain --pull --target production \
            --build-arg POETRY_HTTP_BASIC_AZURE_PASSWORD=${PIPAUTH_POETRY_HTTP_BASIC_AZURE_PASSWORD} \
            --label com.azure.dev.image.build.sourceversion=$(Build.SourceVersion) \
            --label com.azure.dev.image.build.sourcebranchname=$(Build.SourceBranchName) \
            --label com.azure.dev.image.build.buildnumber=$(Build.BuildNumber)
      - task: ECRPushImage@1
        displayName: Push image with 'latest' tag
        condition: and(succeeded(),eq(variables['Build.SourceBranchName'], 'master'))
        inputs:
          awsCredentials: 'dev-azure-devops'
          regionName: 'eu-central-1'
          imageSource: 'imagename'
          sourceImageName: $(imageName)
          sourceImageTag: $(tag)
          repositoryName: $(imageName)
          pushTag: 'latest'
          autoCreateRepository: true
  
      - task: ECRPushImage@1
        displayName: Push image with branch name tag
        condition: and(succeeded(),ne(variables['Build.SourceBranchName'], 'merge'))
        inputs:
          awsCredentials: 'iotahoe-dev-azure-devops'
          regionName: 'eu-central-1'
          imageSource: 'imagename'
          sourceImageName: $(imageName)
          sourceImageTag: $(tag)
          repositoryName: $(imageName)
          pushTag: '$(Build.SourceBranchName)'
          autoCreateRepository: true
  
      - task: ECRPushImage@1
        displayName: Push image with uniq tag
        condition: and(succeeded(),ne(variables['Build.SourceBranchName'], 'merge'))
        inputs:
          awsCredentials: 'dev-azure-devops'
          regionName: 'eu-central-1'
          imageSource: 'imagename'
          sourceImageName: $(imageName)
          sourceImageTag: $(tag)
          repositoryName: $(imageName)
          pushTag: $(tag)
          autoCreateRepository: true
          outputVariable: 'ECR_PUSHED_IMAGE_NAME'
  </code></pre>
  <p>Please let me know if there is anything else I should provide.</p>