Azure / Azure/Azure-Functions

Debug loglevel keeps open on azure

Open
#1,436 5 comments 0 reactions 2 assignees Claimed by @ahmedelnably View on GitHub
premium-plan
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

**Describe the bug**
This Bug is about azure function log level. On local, it is no problem. But after publish to azure, I can't close the debug level. If you try to use `log.IsEnabled(LogLevel.Debug)` to get the value of it, you will always get 1.

**To Reproduce**
Steps to reproduce the behavior:
1.create a azure function, like this:

```
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace LogLevelFunction
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string a = null;
if(log.IsEnabled(LogLevel.Debug)) {
log.LogInformation("Value is true.");
a = "Value is true.";
} else if(log.IsEnabled(LogLevel.Debug)==false){
log.LogInformation("Value is false.");
a = "Value is false.";
}
return (ActionResult)new OkObjectResult(a);
}
}
}
```
2. modify the host.json, like this:

```
{
"version": "2.0",
"logging": {
"logLevel": {
"Function.Function1": "Information",
"Function": "Error"
}
}
}
```
3. run on local.

4. publish and run on azure.

**Expected behavior**
I think the behavior of local and the behavior of azure should be the same

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
You will find when you trigger the function on local. It returns false, but whatever you modify the loglevel on portal, it always return true. Debug loglevel seems always open on azure, it is strange. Isn't it?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.