public static void Main(string[] args)
        {
            // Create the configuration that resides in App.Config.
            LogConfiguration configuration = LogConfiguration.FromConfigSection("BlackBox");

            // Create the log kernel and create a logger.
            LogKernel kernel = new LogKernel(configuration);
            ILogger logger = kernel.GetLogger();

            // Write a message to the logger.
            logger.Write(LogLevel.Information, "Hello World!");

            // Wait for the user to press a key.
            Console.WriteLine("Press ANY key to quit.");
            Console.ReadKey(true);
        }
        public static void Main(string[] args)
        {
            // Create the configuration.
            LogConfiguration configuration = new LogConfiguration();

            // Add a console sink to the configuration.
            configuration.Sinks.Add(new ConsoleSink { Format = "$(time(format='HH:mm:ss')): $(message())" });

            // Create the log kernel and create a logger.
            LogKernel kernel = new LogKernel(configuration);
            ILogger logger = kernel.GetLogger();

            // Write a message to the logger.
            logger.Write(LogLevel.Information, "Hello World!");

            // Wait for the user to press a key.
            Console.WriteLine("Press ANY key to quit.");
            Console.ReadKey(true);
        }
        private void RegisterLogging()
        {
            var configuration = LogConfiguration.FromConfigSection();
            if (configuration == null)
            {
                configuration = new LogConfiguration();
                configuration.Sinks.Add(new TraceSink());
            }

            // Create the kernel.
            var kernel = new LogKernel(configuration);

            // Register the kernel and loggers in the container.
            _kernel.Bind<ILogKernel>().ToConstant(kernel).InSingletonScope();
            _kernel.Bind<ILogger>().ToMethod(x => x.Kernel.Get<ILogKernel>().GetLogger(x.Request.ParentRequest.Service));
        }
Beispiel #4
0
 internal Logger(LogKernel kernel, Type type)
 {
     _kernel = kernel;
     _source = type;
 }