Disable Information Logging

Kuler Master 326 Reputation points
2024-12-16T18:26:28.2633333+00:00

Hello,

How do I disable the logging so I don't see those odd messages in the console (Google Chrome) ??

Whenever I run my blazor 8.0 app the following messages are displayed:

Information: Normalizing '_blazor' to ' LINK

Information: WebSocket connected to LINK

Thank you

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,706 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,635 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tiny Wang-MSFT 2,981 Reputation points Microsoft Vendor
    2024-12-17T07:10:31.4466667+00:00

    I trust the log you referred is the one within the screenshot below.

    User's image

    As we can see they are coming from blazor.web.js file, and the content is related to signlar connection establishment. So that if we want to manage the log, we need to manage the log level of SignalR client logging.

    We can add codes below but it will give us error message "Uncaught Error: Blazor has already started" in the Dev tool console window of the browser, this is because blazor.web.js starts automatically. So that we need to disable auto-start like <script src="{BLAZOR SCRIPT}" autostart="false"></script>

    <script>
        Blazor.start({
          circuit: {
            configureSignalR: function (builder) {
              builder.configureLogging("warning");
            }
          }
        });
    </script>
    

    Then you could see the log disappeared. More details about the log can be seen inside the link I shared above.

    User's image

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Tiny

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,716 Reputation points
    2024-12-16T20:53:00.2433333+00:00

    just set the logging level to desired:

    builder.Logging.SetMinimumLevel(LogLevel.Warning);

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.