Giter Site home page Giter Site logo

Comments (9)

snakefoot avatar snakefoot commented on May 23, 2024 1

I change version and result 2 seconds delay.

Looks like the pre-release-build has improved the performance.

Looked at your test-application. And it seems the "Hide assemblies for callsite" comes from each of the 100 threads setting up their own DI-Container with new NLog-LoggingProvider. Where each the NLog-LoggingProvider marks the same Microsoft-extension-logging-dlls to be excluded in callsite-stacktrace-filtering (if callsite should be used).

The same 100 NLog-LoggingProvider performs implicit Flush on thread-exit (when disposing DI-container), thus also causing the frequent logging of "LogFactory Flush with timeout=15 secs"

from nlog.mongo.

snakefoot avatar snakefoot commented on May 23, 2024 1

@iozcelik There is now an updated nuget-package, that should match the pre-release:

https://www.nuget.org/packages/NLog.Mongo/

from nlog.mongo.

snakefoot avatar snakefoot commented on May 23, 2024

Try changing from this:

<target name="mongoTest" xsi:type="AsyncWrapper">

To include overflowAction (Default is Discard):

<target name="mongoTest" xsi:type="AsyncWrapper" overflowAction="Grow">

Maybe missing loglines is because you have configured cappedCollectionSize.

if (!CappedCollectionSize.HasValue || CollectionExists(database, collectionName))
return database.GetCollection<BsonDocument>(collectionName);
// create capped
var options = new CreateCollectionOptions
{
Capped = true,
MaxSize = CappedCollectionSize,
MaxDocuments = CappedCollectionMaxItems
};

Looks like #25 also complains about startup delay. Have created #41 for using NLog InternalLogger for performance measurements when connecting.

Maybe you can try this pre-release-nuget-package and report the output from NLog InternalLogger (At Debug-Level):

https://ci.appveyor.com/project/LoreSoft/nlog-mongo/builds/33782375/artifacts

from nlog.mongo.

iozcelik avatar iozcelik commented on May 23, 2024

I change and try pre-nuget package but it is same.
image
As you can see from screenshot, the delay is almost 2 minutes. I think miliseconds delays are acceptable but over minutes delays are huge.

from nlog.mongo.

snakefoot avatar snakefoot commented on May 23, 2024

from nlog.mongo.

iozcelik avatar iozcelik commented on May 23, 2024

I attach all file from last run.

logMongoTest.txt

from nlog.mongo.

snakefoot avatar snakefoot commented on May 23, 2024

from nlog.mongo.

iozcelik avatar iozcelik commented on May 23, 2024

Sorry, l forget change version before last test. I change version and result 2 seconds delay.
image

All code is here:

public static class NLogTest {
        public static void StartTest() {
            var logger = LogManager.GetCurrentClassLogger();
            try {
                var config = new ConfigurationBuilder()
                   .SetBasePath(System.IO.Directory.GetCurrentDirectory())
                   .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                   .Build();

                logger.Info("Başladı");
                for (int i = 0; i < 100; i++) {
                    new Thread(() => {
                        var servicesProvider = BuildDi(config);
                        using (servicesProvider as IDisposable) {
                            var runner = servicesProvider.GetRequiredService<LogTest>();
                            runner.DoAction("NLog",i);
                        }
                    }).Start();
                }
                Console.WriteLine("Press ANY key to exit");
                Console.ReadKey();

            } catch (Exception ex) {
                Console.WriteLine(ex);

                logger.Error(ex, "Stopped program because of exception");
                throw;
            } finally {
                Console.WriteLine("Logger kapandı");

                LogManager.Shutdown();
            }
        }

        private static IServiceProvider BuildDi(IConfiguration config) {
            return new ServiceCollection()
               .AddTransient<LogTest>() 
               .AddLogging(loggingBuilder => {
                   loggingBuilder.ClearProviders();
                   loggingBuilder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                   loggingBuilder.AddNLog(config);
               })
               .BuildServiceProvider();
        }

    }

public class LogTest {
        private readonly ILogger<LogTest> _logger;

        public LogTest(ILogger<LogTest> logger) {
            _logger = logger;
        }

        public void DoAction(string name,int id) {
            for (int i = 0; i < 100; i++) {
                _logger.LogInformation(id, "Doing hard work! {Action}", name);
            }
        }
    }

from nlog.mongo.

iozcelik avatar iozcelik commented on May 23, 2024

Looked at your test-application. And it seems the "Hide assemblies for callsite" comes from each of the 100 threads setting up their own DI-Container with new NLog-LoggingProvider. Where each the NLog-LoggingProvider marks the same Microsoft-extension-logging-dlls to be excluded in callsite-stacktrace-filtering (if callsite should be used).

Thanks I see, however my main aim is testing nlog mongo and I think I will use in my service.

from nlog.mongo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.