'Disable signalr console logging

using signalR in Javascript client. (backend is asp.net core).

I want to disable the console logging for signalr. basically, to stop this:

enter image description here

I have done this (but makes no difference):

var connection = new signalR.HubConnectionBuilder().withUrl("./NotificationUserHub").build();
connection.serverTimeoutInMilliseconds = 100000;
connection.logging = false;

someone please correct me?

thanks



Solution 1:[1]

You just need to add this to your code .configureLogging(signalR.LogLevel.None) like this:

var connection = new signalR.HubConnectionBuilder().configureLogging(signalR.LogLevel.None).withUrl("./NotificationUserHub").build();

You can see more log levels in the Microsoft Documentation.

Solution 2:[2]

I found a way to disable logging.

import { ILogger, LogLevel, HubConnectionBuilder } from "@aspnet/signalr";

export class MyLogger implements ILogger {
    log(logLevel: LogLevel, message: string) {
        // Use `message` and `logLevel` to record the log message to your own system
    }
}

// later on, when configuring your connection...

let connection = new HubConnectionBuilder()
    .withUrl("/my/hub/url")
    .configureLogging(new MyLogger())
    .build();

This might help someone.

Solution 3:[3]

May 2022 update:

import { HubConnectionBuilder, LogLevel } from "@microsoft/signalr";
const connection = new HubConnectionBuilder()
    .withUrl()
    .withAutomaticReconnect()
    .configureLogging(LogLevel.None)
    .build();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kiril1512
Solution 2 supernerd
Solution 3 munirmuratovic