コード例 #1
0
 /// <summary>
 /// Adds the elements of an array to the end of this LoggerConfigCollection.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the end of this LoggerConfigCollection.
 /// </param>
 public virtual void AddRange(LoggerConfig[] items)
 {
     foreach (LoggerConfig item in items)
     {
         this.List.Add(item);
     }
 }
コード例 #2
0
                /// <summary>Combines the configs for the handlers in the distribution set with the group's configuration to generate the activeLoggerConfig, the cached summary of the config that is used to gate allocation and delivery of messages.</summary>
                public bool UpdateActiveLoggerConfig()
                {
                    LoggerConfig distHandlerLoggerConfigOr = LoggerConfig.None;			//!< the logical "or" of the gates for our distribution handlers at the time they were added.
                    LoggerConfig distHandlerLoggerConfigAnd = LoggerConfig.None;	    //!< the logical "and" of the gates for our distribution handlers at the time they were added.

                    distHandlerLoggerConfigOr.GroupName = DistGroupName;

                    foreach (DistHandlerInfo dhInfo in distHandlerInfoList)
                    {
                        distHandlerLoggerConfigOr |= dhInfo.LoggerConfig;
                        distHandlerLoggerConfigAnd &= dhInfo.LoggerConfig;
                    }

                    LoggerConfig updatedLoggerConfig = distHandlerLoggerConfigOr & groupLoggerConfigSetting;
                    if (Disabled)
                        updatedLoggerConfig.LogGate = LogGate.None;

                    if (!distHandlerLoggerConfigAnd.SupportsReferenceCountedRelease)
                        updatedLoggerConfig.SupportsReferenceCountedRelease = false;

                    if (activeLoggerConfig.Equals(updatedLoggerConfig))
                        return false;

                    activeLoggerConfig = updatedLoggerConfig;
                    return true;
                }
コード例 #3
0
 public RoleRepository(HuntContext context)
 {
     this.context = context;
     LoggerConfig.ReadConfiguration();
 }
コード例 #4
0
 public SqlConnectionCreator(LoggerConfig config)
 {
     _config = config;
 }
コード例 #5
0
 public GrpcNlogger(string name, LoggerConfig loggerConfig, IServiceProvider serviceProvider)
 {
     _config          = loggerConfig;
     _serviceProvider = serviceProvider;
     logName          = name;
 }
コード例 #6
0
 public LoggerFactory()
 {
     _config = new ConfigurationHandler().Read();
 }
コード例 #7
0
 internal static void AddLogger(this IServiceCollection services, LoggerConfig config = null)
 {
     services.AddSingleton <ILogger>(new SerilogLogger(config));
 }
コード例 #8
0
 /// <summary>
 /// Adds an instance of type LoggerConfig to the end of this LoggerConfigCollection.
 /// </summary>
 /// <param name="value">
 /// The LoggerConfig to be added to the end of this LoggerConfigCollection.
 /// </param>
 public virtual void Add(LoggerConfig value)
 {
     this.List.Add(value);
 }
コード例 #9
0
                /// <summary>Basic constructor.</summary>
                /// <param name="name">Defines the LMH name.</param>
                /// <param name="logGate">Defines the LogGate value for messages handled here.  Messages with MesgType that is not included in this gate will be ignored.</param>
                /// <param name="includeFileAndLines">Indicates if this handler should record and save source file and line numbers.</param>
                /// <param name="supportReferenceCountedRelease">Indicates if this logger supports reference counted log message release.</param>
                public CommonLogMessageHandlerBase(string name, LogGate logGate, bool includeFileAndLines, bool supportReferenceCountedRelease)
                {
                    this.name = name;
                    loggerConfig = new LoggerConfig() { GroupName = "LMH:" + name, LogGate = logGate, RecordSourceStackFrame = includeFileAndLines, SupportsReferenceCountedRelease = supportReferenceCountedRelease };

                    logger = new LogMesgHandlerLogger(this);
                }
コード例 #10
0
 /// <summary>
 /// Adds an element with the specified key and value to this StringToLoggerConfigMap.
 /// </summary>
 /// <param name="key">
 /// The String key of the element to add.
 /// </param>
 /// <param name="value">
 /// The LoggerConfig value of the element to add.
 /// </param>
 public virtual void Add(String key, LoggerConfig value)
 {
     this.Dictionary.Add(key, value);
 }
コード例 #11
0
 /// <summary>
 /// Determines whether this StringToLoggerConfigMap contains a specific value.
 /// </summary>
 /// <param name="value">
 /// The LoggerConfig value to locate in this StringToLoggerConfigMap.
 /// </param>
 /// <returns>
 /// true if this StringToLoggerConfigMap contains an element with the specified value;
 /// otherwise, false.
 /// </returns>
 public virtual bool ContainsValue(LoggerConfig value)
 {
     foreach (LoggerConfig item in this.Dictionary.Values)
     {
         if (item == value)
             return true;
     }
     return false;
 }
コード例 #12
0
        private static void Configure(LoggerConfig config, IConfiguration configuration)
        {
            config = config ?? new LoggerConfig();
            var jsonLoggin = configuration.GetSection("JsonLogging").Get <LoggerConfig>();

            config.LogLevel            = jsonLoggin.LogLevel;
            config.IgnoreMicrosoftLogs = jsonLoggin.IgnoreMicrosoftLogs;
            config.IgnoreSystemNetLogs = jsonLoggin.IgnoreSystemNetLogs;
            config.UseFileLogger       = jsonLoggin.UseFileLogger;
            config.LogFilePath         = jsonLoggin.LogFilePath;
            config.ServiceName         = configuration.GetValue <string>(nameof(config.ServiceName)) ?? config.ServiceName;
            config.ServiceVersion      = configuration.GetValue <string>(nameof(config.ServiceVersion)) ?? config.ServiceVersion;

            var attributes = LoggerConfig.GetDefualtLayout();

            // если передавались поля для расширения лога, то добавляем их
            if (config.LogFields != null)
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <JsonField, JsonAttribute>().ConvertUsing <JsonAttributeTypeConverter>();
                    cfg.CreateMap <JsonLayoutField, JsonLayout>();
                });
                var jsonAttributes = config.LogFields.Select(x => Mapper.Map <JsonField, JsonAttribute>(x));
                attributes.AddRange(jsonAttributes);
            }

            // добавляем все поля лога в JsonLayout и записываем в конфиг
            var jsonLayout = new JsonLayout();

            attributes.ForEach(x => jsonLayout.Attributes.Add(x));

            var consoleTarget = new ConsoleTarget("all_log")
            {
                Layout = jsonLayout
            };

            var fileTarget = new FileTarget("all_log_file")
            {
                Layout          = jsonLayout,
                Header          = "Log was created at ${longdate}${newline}",
                Footer          = "Log was archived at ${longdate}",
                FileName        = $"{config.LogFilePath}\\current.log",
                ArchiveFileName = $"{config.LogFilePath}\\archive\\archive_${{shortdate}}.{{##}}.log"
            };

            var nullTarget = new NullTarget("blackHole");

            // создаем конфиг NLog
            var nlogConfig = new LoggingConfiguration();

            // добавление переменных для NLog
            nlogConfig.Variables.Add(nameof(config.ServiceName), config.ServiceName);
            nlogConfig.Variables.Add(nameof(config.ServiceVersion), config.ServiceVersion);

            if (config.IgnoreMicrosoftLogs)
            {
                nlogConfig.AddRule(NLog.LogLevel.FromOrdinal((int)config.LogLevel), NLog.LogLevel.Off, nullTarget, "Microsoft.*", true);
            }
            if (config.IgnoreSystemNetLogs)
            {
                nlogConfig.AddRule(NLog.LogLevel.FromOrdinal((int)config.LogLevel), NLog.LogLevel.Off, nullTarget, "System.Net.*", true);
            }
            nlogConfig.AddRule(NLog.LogLevel.FromOrdinal((int)config.LogLevel), NLog.LogLevel.Off, consoleTarget);
            if (config.UseFileLogger)
            {
                nlogConfig.AddRule(NLog.LogLevel.FromOrdinal((int)config.LogLevel), NLog.LogLevel.Off, fileTarget);
            }

            nlogConfig.AddTarget(nullTarget);
            nlogConfig.AddTarget(consoleTarget);
            if (config.UseFileLogger)
            {
                nlogConfig.AddTarget(fileTarget);
            }

            LogManager.Configuration = nlogConfig;
        }
コード例 #13
0
 /// <summary>
 /// Добавляем логирование в формате json
 /// </summary>
 /// <param name="webHostBuilder"></param>
 /// <param name="fields">Расширяем поля лога</param>
 /// <param name="appName">Имя приложения</param>
 /// <returns></returns>
 public static IWebHostBuilder AddJsonLogger(this IWebHostBuilder webHostBuilder, LoggerConfig config = null)
 {
     return(webHostBuilder
            .ConfigureLogging(logging =>
     {
         logging.ClearProviders();
         logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
     })
            .UseNLog()
            .ConfigureServices((ctx, srv) =>
     {
         Configure(config, ctx.Configuration);
     }));
 }
コード例 #14
0
 /// <summary>
 /// Добавляем логирование в формате json
 /// </summary>
 /// <param name="services"></param>
 /// <param name="fields">Расширяем поля лога</param>
 /// <param name="appName">Имя приложения</param>
 public static void AddJsonLogger(this IServiceCollection services, IConfiguration configuration, LoggerConfig config = null)
 {
     services.AddLogging(logging =>
     {
         logging.ClearProviders();
         logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
         logging.AddNLog(new NLogProviderOptions {
             CaptureMessageTemplates = true, CaptureMessageProperties = true
         });
         Configure(config, configuration);
     });
 }
コード例 #15
0
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this LoggerConfigCollection
 /// </summary>
 /// <param name="value">
 /// The LoggerConfig value to locate in the LoggerConfigCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(LoggerConfig value)
 {
     return this.List.IndexOf(value);
 }
コード例 #16
0
 /// <summary>
 /// Removes the first occurrence of a specific LoggerConfig from this LoggerConfigCollection.
 /// </summary>
 /// <param name="value">
 /// The LoggerConfig value to remove from this LoggerConfigCollection.
 /// </param>
 public virtual void Remove(LoggerConfig value)
 {
     this.List.Remove(value);
 }
コード例 #17
0
 public GrpcLoggerProvider(IServiceProvider serviceProvider, LoggerConfig config)
 {
     _serviceProvider = serviceProvider;
     _loggerConfig = config ?? new LoggerConfig();
 }
コード例 #18
0
 public Logger()
 {
     //_config = loggerConfig;
     _config = new LoggerConfig();
 }
コード例 #19
0
 /// <summary>
 /// Configures modules.
 /// </summary>
 /// <param name="app"><see cref="IApplicationBuilder"/> instance.</param>
 /// <param name="env"><see cref="IHostingEnvironment"/> instance.</param>
 /// <param name="logger"><see cref="ILoggerFactory"/> instance.</param>
 /// <remarks>This method gets called by the runtime. Use this method to configure the HTTP request pipeline.</remarks>
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)
 {
     LoggerConfig.Register(logger, this.Configuration);
     EnvironmentConfig.Register(app, env);
     WebServerConfig.Register(app, this.Configuration);
 }
コード例 #20
0
 public PartialHuntingRepository(HuntContext context)
 {
     this.context = context;
     LoggerConfig.ReadConfiguration();
 }
コード例 #21
0
 public TextFileReader()
 {
     _config = new ConfigurationHandler().Read();
 }
コード例 #22
0
 internal void BuildLogger()
 {
     this.logger = (global::Serilog.Core.Logger)LoggerConfig.CreateLogger()
                   .ForContext("SourceContext", this.nameOfLogger);
 }
コード例 #23
0
        public override void CreateLogger(LoggerConfig config)
        {
            if (CreateUI == false)
            {
                return;
            }

            _loggerConfig = config;

            _loggerViewModel = new LoggerViewModel();
            _loggerViewModel.StreamChanged += (sender, args) =>
            {
                OnStreamChanged(new StreamChangedEventArgs(args.Name, args.Enabled));
            };

            _filteredView        = CollectionViewSource.GetDefaultView(_loggerViewModel.LogItems);
            _filteredView.Filter = a => ((LoggerViewModel.LogItem)a).Stream.Enabled;
            _filteredView.GroupDescriptions.Add(new PropertyGroupDescription("UpdateNumber"));

            _loggerWindow = new LoggerWindow
            {
                Top    = config.Top,
                Left   = config.Left,
                Width  = config.Width,
                Height = config.Height
            };
            _loggerWindow.StreamsListView.DataContext = _loggerViewModel.Streams;
            _loggerWindow.LogListView.DataContext     = _filteredView;

            _loggerWindow.SaveLogFile       += (sender, args) => { SaveLogToFile(); };
            _loggerWindow.EnableAllStreams  += (sender, args) => { _loggerViewModel.EnableAllStreams(); };
            _loggerWindow.DisableAllStreams += (sender, args) => { _loggerViewModel.DisableAllStreams(); };
            _loggerWindow.IsVisibleChanged  += (sender, args) => _loggerConfig.Visible = _loggerWindow.IsVisible;
            _loggerWindow.LocationChanged   += (sender, args) => _loggerLocationJustChanged = true;
            _loggerWindow.SizeChanged       += (sender, args) => _loggerLocationJustChanged = true;
            _loggerWindow.SoloRequested     += (sender, e) =>
            {
                foreach (var stream in _loggerViewModel.Streams)
                {
                    if (stream != e.StreamItem)
                    {
                        stream.Enabled = false;
                    }
                    else
                    {
                        stream.Enabled = true;
                    }
                }
            };

            if (_loggerConfig.Visible)
            {
                _loggerWindow.Show();
            }

            _windows.Add(_loggerWindow);

            _loggerScrollViewer = GetDescendantByType(_loggerWindow.LogListView, typeof(ScrollViewer)) as ScrollViewer;

            WindowHelper.EnsureOnScreen(_loggerWindow);
        }
コード例 #24
0
 public override void CreateLogger(LoggerConfig config)
 {
 }
コード例 #25
0
ファイル: ConsoleLogger.cs プロジェクト: coolya/SharpProxy
 public ConsoleLogger()
 {
     _config = LoggerConfig.All;
 }
コード例 #26
0
ファイル: UDPLogger.cs プロジェクト: zz412000428/Gaea
 public UDPLogger(LoggerConfig config)
 {
     _host = config.UDP.Host;
     _port = config.UDP.Port;
     uc    = new System.Net.Sockets.UdpClient();
 }
コード例 #27
0
ファイル: ConsoleLogger.cs プロジェクト: coolya/SharpProxy
 public ConsoleLogger(LoggerConfig config)
 {
     _config = config;
 }
コード例 #28
0
ファイル: EditorLogger.cs プロジェクト: Avatarchik/CLogger
 public EditorLogger(LoggerConfig config)
 {
     _config = config;
 }
コード例 #29
0
ファイル: NativeLogger.cs プロジェクト: Avatarchik/CLogger
 public NativeLogger(LoggerConfig config)
 {
     _config = config;
 }
コード例 #30
0
 /// <summary>
 /// Determines whether a specfic LoggerConfig value is in this LoggerConfigCollection.
 /// </summary>
 /// <param name="value">
 /// The LoggerConfig value to locate in this LoggerConfigCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this LoggerConfigCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(LoggerConfig value)
 {
     return this.List.Contains(value);
 }
コード例 #31
0
ファイル: Logger.cs プロジェクト: supertigerzou/GreenField
 public Logger(OwinMiddleware next, ILogger logger) : base(next)
 {
     _logger  = logger;
     _options = LoggerConfig.Init();
 }
コード例 #32
0
 /// <summary>
 /// Inserts an element into the LoggerConfigCollection at the specified index
 /// </summary>
 /// <param name="index">
 /// The index at which the LoggerConfig is to be inserted.
 /// </param>
 /// <param name="value">
 /// The LoggerConfig to insert.
 /// </param>
 public virtual void Insert(int index, LoggerConfig value)
 {
     this.List.Insert(index, value);
 }
コード例 #33
0
 public NetCoreUtilsLogger(LoggerConfig config = null)
 {
     logger = new Logger(config);
 }
コード例 #34
0
 /// <summary>
 /// Initializes a new instance of the LoggerConfigCollection class, containing elements
 /// copied from an array.
 /// </summary>
 /// <param name="items">
 /// The array whose elements are to be added to the new LoggerConfigCollection.
 /// </param>
 public LoggerConfigCollection(LoggerConfig[] items)
 {
     this.AddRange(items);
 }
コード例 #35
0
 public static void Initialize(LoggerConfig config)
 {
     service          = new LoggerService(config);
     displayLevel     = config.DisplayLevel;
     useFullClassName = config.UseFullClassName;
 }
コード例 #36
0
ファイル: FileLogger.cs プロジェクト: zz412000428/Gaea
 public FileLogger(LoggerConfig config)
 {
     SavePath = config.File.Path;
 }
コード例 #37
0
ファイル: Global.asax.cs プロジェクト: jenik90/some
 protected void Application_End()
 {
     LoggerConfig.DisposeLogger();
 }
コード例 #38
0
 public Logger(Action <string> action)
 {
     this.onWrite = action;
     _config      = new LoggerConfig();
 }
コード例 #39
0
 public Logger(LoggerConfig config)
 {
     _config = config;
     _writer = new LoggerWriter(config.LogFile);
 }