您只需要将以下代码添加到您的代码中.configureLogging(signalR.LogLevel.None)
,像这样:
var connection = new signalR.HubConnectionBuilder().configureLogging(signalR.LogLevel.None).withUrl("./NotificationUserHub").build();
您可以在Microsoft文档中查看更多日志级别。
2022年5月更新:
import { HubConnectionBuilder, LogLevel } from "@microsoft/signalr";
const connection = new HubConnectionBuilder()
.withUrl()
.withAutomaticReconnect()
.configureLogging(LogLevel.None)
.build();
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();
这可能会对某些人有所帮助。