Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using NLog;
- using NLog.Targets;
- using NLog.Config;
- using Serilog;
- using Serilog.Sinks.File;
- namespace logspeedtest
- {
- //nlog 4.5.6
- //serilog 2.7.1
- class MainClass
- {
- public static void Main(string[] args)
- {
- String sample = "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of";
- var watch = System.Diagnostics.Stopwatch.StartNew();
- nlog_test(sample,10000);
- //serilog_test(sample,10000);
- watch.Stop();
- var elapsedMs = watch.ElapsedMilliseconds;
- Console.WriteLine("Time taken: " + elapsedMs + " ms");
- }
- static void nlog_test(String sample, int count){
- var config = new LoggingConfiguration();
- var fileTarget = new FileTarget("target2")
- {
- FileName = "${basedir}/nlog.log",
- //Layout = "${longdate} ${level} ${message} ${exception}"
- };
- config.AddTarget(fileTarget);
- config.AddRuleForOneLevel(LogLevel.Info, fileTarget);
- LogManager.Configuration = config;
- Logger logger = LogManager.GetLogger("Example");
- for (int i = 0; i < count;i++){
- logger.Info(sample);
- }
- }
- static void serilog_test(String sample, int count){
- var log = new LoggerConfiguration()
- .WriteTo.File("serilog.log")
- .CreateLogger();
- for (int i = 0; i < count;i++){
- log.Information(sample);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment