Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,6 @@ var dnsZoneIndex = {
sqlServer: 9
search: 10
}
// List of DNS zone indices that correspond to AI-related services.
var aiRelatedDnsZoneIndices = [
dnsZoneIndex.cognitiveServices
dnsZoneIndex.openAI
dnsZoneIndex.aiServices
]

// ===================================================
// DEPLOY PRIVATE DNS ZONES
Expand Down Expand Up @@ -1575,6 +1569,9 @@ module webSiteBackend 'modules/web-sites.bicep' = {
SOLUTION_NAME: solutionSuffix
APP_ENV: 'Prod'
AZURE_CLIENT_ID: backendUserAssignedIdentity.outputs.clientId
AZURE_BASIC_LOGGING_LEVEL: 'INFO'
AZURE_PACKAGE_LOGGING_LEVEL: 'WARNING'
AZURE_LOGGING_PACKAGES: ''
}
// WAF aligned configuration for Monitoring
applicationInsightResourceId: enableMonitoring ? applicationInsights!.outputs.resourceId : null
Expand Down
154 changes: 76 additions & 78 deletions infra/main.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/api/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ SQLDB_DATABASE=
SQLDB_SERVER=
USE_CHAT_HISTORY_ENABLED="True"
APP_ENV="dev"
# Basic application logging (default: INFO level)
AZURE_BASIC_LOGGING_LEVEL=INFO
# Azure package logging (default: WARNING level to suppress INFO)
AZURE_PACKAGE_LOGGING_LEVEL=WARNING
# Comma-separated list of specific logger names to configure (default: empty - no custom loggers)
# Example: AZURE_LOGGING_PACKAGES=azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base
AZURE_LOGGING_PACKAGES=
16 changes: 0 additions & 16 deletions src/api/api/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

router = APIRouter()

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Check if the Application Insights Instrumentation Key is set in the environment variables
Expand All @@ -32,20 +30,6 @@
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")

# Configure logging
logging.basicConfig(level=logging.INFO)

# Suppress INFO logs from 'azure.core.pipeline.policies.http_logging_policy'
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(
logging.WARNING
)
logging.getLogger("azure.identity.aio._internal").setLevel(logging.WARNING)

# Suppress info logs from OpenTelemetry exporter
logging.getLogger("azure.monitor.opentelemetry.exporter.export._base").setLevel(
logging.WARNING
)


@router.get("/fetchChartData")
async def fetch_chart_data():
Expand Down
16 changes: 0 additions & 16 deletions src/api/api/history_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

router = APIRouter()

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Check if the Application Insights Instrumentation Key is set in the environment variables
Expand All @@ -25,20 +23,6 @@
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")

# Configure logging
logging.basicConfig(level=logging.INFO)

# Suppress INFO logs from 'azure.core.pipeline.policies.http_logging_policy'
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(
logging.WARNING
)
logging.getLogger("azure.identity.aio._internal").setLevel(logging.WARNING)

# Suppress info logs from OpenTelemetry exporter
logging.getLogger("azure.monitor.opentelemetry.exporter.export._base").setLevel(
logging.WARNING
)

# Single instance of HistoryService (if applicable)
history_service = HistoryService()

Expand Down
23 changes: 23 additions & 0 deletions src/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"""


import logging
import os
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand All @@ -21,8 +23,29 @@
from api.api_routes import router as backend_router
from api.history_routes import router as history_router

# Load environment variables
load_dotenv()

# Configure logging
# Basic application logging (default: INFO level)
AZURE_BASIC_LOGGING_LEVEL = os.getenv("AZURE_BASIC_LOGGING_LEVEL", "INFO").upper()
# Azure package logging (default: WARNING level to suppress INFO)
AZURE_PACKAGE_LOGGING_LEVEL = os.getenv("AZURE_PACKAGE_LOGGING_LEVEL", "WARNING").upper()
# Azure logging packages (default: empty list)
AZURE_LOGGING_PACKAGES = [
pkg.strip() for pkg in os.getenv("AZURE_LOGGING_PACKAGES", "").split(",") if pkg.strip()
]

# Basic config: logging.basicConfig(level=logging.INFO)
logging.basicConfig(
level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL, logging.INFO),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

# Package config: Azure loggers set to WARNING to suppress INFO
for logger_name in AZURE_LOGGING_PACKAGES:
logging.getLogger(logger_name).setLevel(getattr(logging, AZURE_PACKAGE_LOGGING_LEVEL, logging.WARNING))


@asynccontextmanager
async def lifespan(fastapi_app: FastAPI):
Expand Down
4 changes: 0 additions & 4 deletions src/api/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

import requests

DEBUG = os.environ.get("DEBUG", "false")
if DEBUG.lower() == "true":
logging.basicConfig(level=logging.DEBUG)

AZURE_SEARCH_PERMITTED_GROUPS_COLUMN = os.environ.get(
"AZURE_SEARCH_PERMITTED_GROUPS_COLUMN"
)
Expand Down
2 changes: 0 additions & 2 deletions src/api/services/chart_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from api.models.input_models import ChartFilters
from common.database.sqldb_service import adjust_processed_data_dates, fetch_chart_data, fetch_filters_data

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions src/api/services/chat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
HOST_NAME = "CKM"
HOST_INSTRUCTIONS = "Answer questions about call center operations"

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down
2 changes: 0 additions & 2 deletions src/api/services/history_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from common.database.cosmosdb_service import CosmosConversationClient
from helpers.azure_credential_utils import get_azure_credential

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


Expand Down