Skip to content

Commit 9fb2c21

Browse files
AjitPadhi-MicrosoftPrajwal-MicrosoftThanusree-MicrosoftCopilot
authored
fix: Merging dev changes to main branch (#773)
* feat: Implementation of Configurable Logging Control via Flag (#756) * Implementation of Configurable Logging Control via Flag * bicep updated * updated bicep * updated custom bicep * Fix typo in CustomizingAzdParameters.md (#772) * Update src/App/app.py fixed blank string issue Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Prajwal-Microsoft <[email protected]> Co-authored-by: Thanusree-Microsoft <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 7912c58 commit 9fb2c21

File tree

7 files changed

+95
-68
lines changed

7 files changed

+95
-68
lines changed

docs/CustomizingAzdParameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
By default this template will use the environment name as the prefix to prevent naming collisions within Azure. The parameters below show the default values. You only need to run the statements below if you need to change the values.
44

55

6-
> To override any of the parameters, run `azd env set <PARAMETER_NAME> <VALUE>` before running `azd up`. On the first azd command, it will prompt you for the environment name. Be sure to choose 3-20 charaters alphanumeric unique name.
6+
> To override any of the parameters, run `azd env set <PARAMETER_NAME> <VALUE>` before running `azd up`. On the first azd command, it will prompt you for the environment name. Be sure to choose 3-20 characters alphanumeric unique name.
77
88
## Parameters
99

infra/main.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,9 @@ module webSite 'modules/web-sites.bicep' = {
11221122
AZURE_SEARCH_STRICTNESS: azureSearchStrictness
11231123
AZURE_OPENAI_EMBEDDING_NAME: embeddingModel
11241124
AZURE_OPENAI_EMBEDDING_ENDPOINT : aiFoundryAiServices.outputs.endpoint
1125+
AZURE_BASIC_LOGGING_LEVEL: 'INFO'
1126+
AZURE_PACKAGE_LOGGING_LEVEL: 'WARNING'
1127+
AZURE_LOGGING_PACKAGES: ''
11251128
SQLDB_SERVER: sqlServerFqdn
11261129
SQLDB_DATABASE: sqlDbName
11271130
USE_INTERNAL_STREAM: useInternalStream

infra/main.json

Lines changed: 62 additions & 59 deletions
Large diffs are not rendered by default.

infra/main_custom.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,9 @@ module webSite 'modules/web-sites.bicep' = {
11261126
AZURE_SEARCH_STRICTNESS: azureSearchStrictness
11271127
AZURE_OPENAI_EMBEDDING_NAME: embeddingModel
11281128
AZURE_OPENAI_EMBEDDING_ENDPOINT : aiFoundryAiServices.outputs.endpoint
1129+
AZURE_BASIC_LOGGING_LEVEL: 'INFO'
1130+
AZURE_PACKAGE_LOGGING_LEVEL: 'WARNING'
1131+
AZURE_LOGGING_PACKAGES: ''
11291132
SQLDB_SERVER: sqlServerFqdn
11301133
SQLDB_DATABASE: sqlDbName
11311134
USE_INTERNAL_STREAM: useInternalStream

src/App/.env.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ AZURE_OPENAI_ENDPOINT=
1212
AZURE_OPENAI_EMBEDDING_NAME="text-embedding-ada-002"
1313
AZURE_OPENAI_EMBEDDING_ENDPOINT=
1414

15+
# Logging settings
16+
AZURE_BASIC_LOGGING_LEVEL="INFO"
17+
AZURE_PACKAGE_LOGGING_LEVEL="WARNING"
18+
# AZURE_LOGGING_PACKAGES="azure.core.pipeline.policies.http_logging_policy,azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base"
19+
1520
# User Interface
1621
UI_TITLE=
1722
UI_LOGO=

src/App/app.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,23 @@
5656
)
5757

5858
# Configure logging
59-
logging.basicConfig(level=logging.INFO)
59+
basic_level = getattr(
60+
logging, config.AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO
61+
)
62+
logging.basicConfig(level=basic_level)
6063

61-
# Suppress INFO logs from 'azure.core.pipeline.policies.http_logging_policy'
62-
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(
63-
logging.WARNING
64+
# Configure Azure package logging levels
65+
azure_packages_env = os.environ.get("AZURE_LOGGING_PACKAGES")
66+
azure_packages = (
67+
[pkg.strip() for pkg in azure_packages_env.split(',') if pkg.strip()]
68+
if azure_packages_env else []
6469
)
65-
logging.getLogger("azure.identity.aio._internal").setLevel(logging.WARNING)
6670

67-
# Suppress info logs from OpenTelemetry exporter
68-
logging.getLogger("azure.monitor.opentelemetry.exporter.export._base").setLevel(
69-
logging.WARNING
71+
package_level = getattr(
72+
logging, config.AZURE_PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING
7073
)
74+
for package in azure_packages:
75+
logging.getLogger(package).setLevel(package_level)
7176

7277

7378
def create_app():

src/App/backend/common/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def __init__(self):
3535
"APPLICATIONINSIGHTS_CONNECTION_STRING"
3636
)
3737

38+
# Azure Logging Configuration
39+
self.AZURE_BASIC_LOGGING_LEVEL = os.environ.get(
40+
"AZURE_BASIC_LOGGING_LEVEL", "INFO"
41+
)
42+
self.AZURE_PACKAGE_LOGGING_LEVEL = os.environ.get(
43+
"AZURE_PACKAGE_LOGGING_LEVEL", "WARNING"
44+
)
45+
3846
self.DEBUG = os.environ.get("DEBUG", "false")
3947

4048
# Current minimum Azure OpenAI version supported

0 commit comments

Comments
 (0)