日志文件的Jsnlog问题

时间:2019-04-09 15:29:22

标签: angular typescript jsnlog

我使用的是带有web api .netcore的angular 7,用于日志记录时,我使用JSNLOG,我可以在日志文件中写入我在日志中写的内容,与此同时,我在日志记录中发现了很多不需要的信息它保存在我们的文件中

 Log.Logger = new LoggerConfiguration()
                .WriteTo.Console()
                .ReadFrom.Configuration(Configuration)
                .Destructure.JsonNetTypes()
                .CreateLogger();
          CreateWebHostBuilder(args).Build().Run();


var jsnlogConfiguration =
      new JsnlogConfiguration
      {
        serverSideMessageFormat = "Sent: %date, %message",
        enabled = false,
        serverSideLogger = "Serilog",

        loggers = new List<Logger> {
          new Logger {
              name = "Serilog",
              disallow="^(App)"
          }
        }
      };

this.logger.GetLogger(this.loggerName).info('Document component initialisé');
this.logger.GetLogger(this.loggerName).error('ERREUR TEST');
this.logger.GetLogger(this.loggerName).debug("debug client log message");
this.logger.GetLogger(this.loggerName).info("info client log message");
this.logger.GetLogger(this.loggerName).warn({ msg: 'warn client log message - logging object', x: 5, y: 88 });
    this.logger.GetLogger(this.loggerName).error(function() { return "error client log message - returned by function"; });
    this.logger.GetLogger(this.loggerName).fatal("fatal client log message");
    this.logger.GetLogger(this.loggerName).fatalException("Something went wrong!", "test karim");
    loggerSrvc.GetLogger("NG_App").trace('App: Test LogLevel 1000');
    loggerSrvc.GetLogger("NG_App").debug('App: Test LogLevel 2000');
    loggerSrvc.GetLogger("NG_App").info('App: Test LogLevel 3000');
    loggerSrvc.GetLogger("NG_App").warn('App: Test LogLevel 4000');
    loggerSrvc.GetLogger("NG_App").error('App: Test LogLevel 5000');
    loggerSrvc.GetLogger("NG_App").fatal('App: Test LogLevel 6000');

部分结果是:

我们不需要这部分

2019-04-09 10:49:37.399 -04:00 [DBG] The request has an origin header: 'http://localhost:5004'.
2019-04-09 10:49:37.400 -04:00 [INF] CORS policy execution failed.
2019-04-09 10:49:37.400 -04:00 [INF] Request origin http://localhost:5004 does not have permission to access the resource.
2019-04-09 10:49:37.400 -04:00 [DBG] POST requests are not supported
2019-04-09 10:49:37.400 -04:00 [DBG] Connection id "0HLLSVAAHMS5E", Request id "0HLLSVAAHMS5E:00000003": started reading request body.
2019-04-09 10:49:37.400 -04:00 [DBG] Connection id "0HLLSVAAHMS5E", Request id "0HLLSVAAHMS5E:00000003": done reading request body.

我们需要这部分

2019-04-09 10:49:37.400 -04:00 [DBG] App: Test LogLevel 2000
2019-04-09 10:49:37.401 -04:00 [INF] App: Test LogLevel 3000
2019-04-09 10:49:37.401 -04:00 [WRN] App: Test LogLevel 4000
2019-04-09 10:49:37.401 -04:00 [ERR] App: Test LogLevel 5000
2019-04-09 10:49:37.401 -04:00 [FTL] App: Test LogLevel 6000
2019-04-09 10:49:37.401 -04:00 [INF] Document component initialisé
2019-04-09 10:49:37.401 -04:00 [ERR] ERREUR TEST
2019-04-09 10:49:37.401 -04:00 [DBG] debug client log message
2019-04-09 10:49:37.401 -04:00 [INF] info client log message

我们不需要这部分

2019-04-09 10:49:37.403 -04:00 [INF] Executing endpoint 
'Drc.Gcc.ServicesInternes.UI.Web.Controllers.DocumentController.AvoirAccesGcc (Drc.Gcc.ServicesInternes.UI.Web)'
2019-04-09 10:49:37.403 -04:00 [INF] Executing endpoint 'Drc.Gcc.ServicesInternes.UI.Web.Controllers.DocumentController.ObtenirListNomsDocument (Drc.Gcc.ServicesInternes.UI.Web)'
2019-04-09 10:49:37.429 -04:00 [WRN] [[[]],[[]],[[]]]
2019-04-09 10:49:37.430 -04:00 [ERR] error client log message - returned by function
2019-04-09 10:49:37.430 -04:00 [FTL] fatal client log message
2019-04-09 10:49:37.430 -04:00 [FTL] [[[]],[[]]]

0 个答案:

没有答案