09Observability

Logging & Monitoring

Transformation of raw logs into actionable insights. Learn how to secure sensitive data, group outputs, and create professional build summaries.

Interactive Log Dashboard

Live Preview
GitHub Actions Log Viewer
Notice

Checking environment dependencies...

echo "API_KEY: " ***(Value Masked)
Warning

src/index.js:42 - This function is deprecated

Error

Database connection timed out (retry 2/3)

Workflow Summary Rendering

✅ Build Report

CheckResultTime
Install✅ Pass12s
Tests✅ Pass34s
Build✅ Pass21s

Grouping

Collapse verbose steps into clean folders to keep long workflow logs readable.

::group::

Masking

Force GitHub to redact secrets like passwords or keys with '***' automatically.

::add-mask::

Annotations

Create red/yellow/blue UI banners for errors, warnings, and info notices.

::error::

Mastering Log Commands

How to use workflow commands and job controls effectively.

1

Markdown Summaries

Writing to $GITHUB_STEP_SUMMARY creates a dedicated tab on the GitHub Actions page. Perfect for test reports, build tables, and final tallies.

Pro Tip: Supports full GitHub Flavored Markdown (GFM).
2

Artifact Persistence

Artifacts are uploaded files (like server logs or build binaries) that persist long after the runner is destroyed. Use 'if: always()' to ensure they upload on failure.

Pro Tip: Set retention periods to manage storage costs.
3

Failure Notification Chains

By using 'if: failure()', you can trigger a secondary job that sends a Slack/Discord notification or opens an issue ONLY when the main job fails.

Pro Tip: Perfect for on-call alerting systems.

Full Workflow Reference

Copy this template to implement professional logging today.

.github/workflows/logging.yml
# Learn - Logging and Monitoring
name: Learn - Logging and Monitoring

on:
  workflow_dispatch:
  push:
    branches: [master]

jobs:
  logging-examples:
    name: "Logging Techniques"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # 1. Grouping logs
      - name: "Technique 1 — Grouped logs"
        run: |
          echo "::group::đŸ“Ļ Installing packages"
          echo "Installing express..."
          echo "All packages installed!"
          echo "::endgroup::"

      # 2. Notices, Warnings and Errors
      - name: "Technique 2 — Coloured annotations"
        run: |
          echo "::notice::â„šī¸ This is an info notice"
          echo "::warning::âš ī¸ This is a warning"
          echo "::error::❌ This is an error annotation"

      # 3. Masking secrets
      - name: "Technique 3 — Masking secrets"
        run: |
          MY_SECRET="super-secret-password-123"
          echo "::add-mask::$MY_SECRET"
          echo "Secret is: $MY_SECRET"

      # 4. Creating a Summary
      - name: "Technique 4 — Step summary"
        run: |
          echo "## ✅ Build Report" >> $GITHUB_STEP_SUMMARY
          echo "| Check | Result |" >> $GITHUB_STEP_SUMMARY
          echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
          echo "| Build | ✅ Pass |" >> $GITHUB_STEP_SUMMARY

      # 5. Saving Artifacts
      - name: "Technique 5 — Upload logs"
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: app-logs
          path: logs/

  alert-on-failure:
    name: "Alert — Notification on Failure"
    runs-on: ubuntu-latest
    needs: logging-examples
    if: failure()
    steps:
      - name: "Print failure details"
        run: echo "🚨 The workflow FAILED!"