Git Product home page Git Product logo

Comments (5)

bonesoul avatar bonesoul commented on July 30, 2024

only console.write reference is in the demo project? are you sure the log lines you mention are from uhttpsharp?

from uhttpsharp.

beppe9000 avatar beppe9000 commented on July 30, 2024

This one, for example:

Logger.InfoFormat("Embedded uhttpserver started.");

from uhttpsharp.

sirkris avatar sirkris commented on July 30, 2024

Bump! I would really love to know how to disable this annoying message every time I use the library:

Exception occured resolving a log provider. Logging for this assembly uhttpsharp
, Version=0.1.5653.28566, Culture=neutral, PublicKeyToken=null is disabled. Syst
em.TypeInitializationException: The type initializer for 'uhttpsharp.Logging.Log
Providers.ColouredConsoleLogProvider' threw an exception. ---> System.InvalidOpe
rationException: System.Console or System.ConsoleColor type not found
at uhttpsharp.Logging.LogProviders.ColouredConsoleLogProvider..cctor() in c:
Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\App_Packages\LibLog.3.1\LibLo
g.cs:line 1629
--- End of inner exception stack trace ---
at uhttpsharp.Logging.LogProviders.ColouredConsoleLogProvider.IsLoggerAvailab
le() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\App_Packages\LibLo
g.3.1\LibLog.cs:line 1645
at uhttpsharp.Logging.LogProvider.ResolveLogProvider() in c:\Users\shani\Docu
ments\GitHub\uHttpSharp\uhttpsharp\App_Packages\LibLog.3.1\LibLog.cs:line 453

Why can't you just let the exception bubble up so I can catch it?

from uhttpsharp.

isen-ng avatar isen-ng commented on July 30, 2024

Do this for a work around:

        static YourClass()
        {
            LogProvider.LogProviderResolvers.Add(
                new Tuple<LogProvider.IsLoggerAvailable, LogProvider.CreateLogProvider>(() => true,
                    () => NullLoggerProvider.Instance));
        }

        public class NullLoggerProvider : ILogProvider
        {
            public static readonly NullLoggerProvider Instance = new NullLoggerProvider();
            
            private static readonly ILog NullLogInstance = new NullLog();
            
            public ILog GetLogger(string name)
            {
                return NullLogInstance;
            }

            public IDisposable OpenNestedContext(string message)
            {
                return null;
            }

            public IDisposable OpenMappedContext(string key, string value)
            {
                return null;
            }
            
            public class NullLog : ILog
            {
                public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null, params object[] formatParameters)
                {
                    // do nothing
                    return true;
                }
            }
        }

from uhttpsharp.

robie2011 avatar robie2011 commented on July 30, 2024

same issue. Workaround didn't work.

from uhttpsharp.

Related Issues (15)

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.