File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
ServiceControl.Infrastructure.Metrics
ServiceControl.Infrastructure Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 11namespace ServiceControl . Infrastructure . Metrics
22{
33 using System ;
4+ using System . Globalization ;
5+ using System . Runtime . CompilerServices ;
6+ using System . Text ;
47 using System . Threading ;
58 using System . Threading . Tasks ;
69
@@ -49,8 +52,8 @@ void Print()
4952 var values = metrics . GetMeterValues ( ) ;
5053 foreach ( var metricSet in values )
5154 {
52- printLine (
53- $ " { metricSet . Name , - 40 } ; { metricSet . Current : F } ; { metricSet . Average15 : F } ; { metricSet . Average60 : F } ; { metricSet . Average300 : F } " ) ;
55+ FormattableString x = $ " { metricSet . Name } ; { metricSet . Current : F } ; { metricSet . Average15 : F } ; { metricSet . Average60 : F } ; { metricSet . Average300 : F } " ;
56+ printLine ( x . ToString ( CultureInfo . InvariantCulture ) ) ;
5457 }
5558 }
5659
Original file line number Diff line number Diff line change @@ -57,11 +57,26 @@ public static void ConfigureLogging(LoggingSettings loggingSettings)
5757 FinalMinLevel = LogLevel . Warn
5858 } ;
5959
60+
6061 nlogConfig . LoggingRules . Add ( aspNetCoreRule ) ;
6162 nlogConfig . LoggingRules . Add ( httpClientRule ) ;
6263
6364 nlogConfig . LoggingRules . Add ( new LoggingRule ( "*" , loggingSettings . LogLevel , consoleTarget ) ) ;
6465
66+ var csvMetricsTarget = new FileTarget
67+ {
68+ Name = "csvMetrics" ,
69+ ArchiveEvery = FileArchivePeriod . Day ,
70+ FileName = Path . Combine ( loggingSettings . LogPath , "metrics/${shortdate}.csv" ) ,
71+ ArchiveFileName = Path . Combine ( loggingSettings . LogPath , "metrics/logfile.{#}.csv" ) ,
72+ ArchiveNumbering = ArchiveNumberingMode . DateAndSequence ,
73+ Layout = new SimpleLayout ( "${longdate};${level};${logger};${message}" ) ,
74+ MaxArchiveFiles = 14 ,
75+ ArchiveAboveSize = 30 * megaByte ,
76+ CreateDirs = true
77+ } ;
78+ nlogConfig . LoggingRules . Add ( new LoggingRule ( "Metrics" , loggingSettings . LogLevel , csvMetricsTarget ) ) ;
79+
6580 if ( ! AppEnvironment . RunningInContainer )
6681 {
6782 nlogConfig . LoggingRules . Add ( new LoggingRule ( "*" , loggingSettings . LogLevel , fileTarget ) ) ;
You can’t perform that action at this time.
0 commit comments