nlog

NLog custom LayoutRenderer is rendering log events as empty string

旧城冷巷雨未停 提交于 2019-12-13 02:46:24
问题 This is my environment: Visual Studio 2017 Project's .NET runtime version is 4.6.2 XUnit version 2.3.1 NLog version 4.4.12 Fluent Assertions 4.19.4 The problem From the sample code below which can be run to reproduce the problem, we have 2 custom LayoutRenderer : RendererOne and RendererTwo . Those 2 are then used in tests TestA and TestB respectively. When i run the test one at a time, I do not get any problem. However, if were to run them in one go example via XUnit's "Run All" button, I

NLog and SQLite Error

南笙酒味 提交于 2019-12-13 02:17:35
问题 I am trying to get NLog to properly log to a SQLite database. I am able to interact with the SQLite database aside from NLog . When I force Internal Logging of NLog , I see the following error: Error initializing target Database Target[db] System.TypeLoadException: Could not load type 'System.Data.SQLite' from assembly 'NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'. My NLog configuration has the following parameters: dbProvider="System.Data.SQLite" keepConnection=

IAutofacActionFilter injecting a logger

杀马特。学长 韩版系。学妹 提交于 2019-12-13 02:04:41
问题 I'm using NLog with this module: public class LoggingModule : Autofac.Module { protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration) { registration.Preparing += OnComponentPreparing; registration.Activated += (sender, e) => InjectLoggerProperties(e.Instance); } private static void OnComponentPreparing(object sender, PreparingEventArgs e) { var t = e.Component.Activator.LimitType; e.Parameters = e.Parameters.Union( new[

index format change daily to weekly

。_饼干妹妹 提交于 2019-12-13 00:55:17
问题 I am currently sending my Log from Nlog to ElasticSearch. I am creating Index daily, and send Logs to that index. I want to create Index Weekly, so I want to change config file. I do index creation in NLog configuration file. index = "logstash-${date:format=yyyy.MM.dd}" My NLog Configuration part : <target xsi:type="ElasticSearch" index = "logstash-${date:format=yyyy.MM.dd}" uri="http://localhost:9200" includeAllProperties ="true"> </target> I found in some forums (https://github.com/logstash

NLog with DNX Core 5.0

最后都变了- 提交于 2019-12-12 22:07:03
问题 I am attempting to implement NLog logging using ASP.Net 5 and MVC 6. Be default, both DNX 451 and DNX Core 50 are included in the project template. I am attempting to implement NLog Logging by following the example here. However, in the sample app, there is the following line - #if !DNXCORE50 factory.AddNLog(new global::NLog.LogFactory()); #endif And if I run the app, this line never gets hit because the mvc application has dnx core 50 installed by default. Is there any loggers that are

Reading NLog.config from NLog in API REST .NET

送分小仙女□ 提交于 2019-12-12 16:24:43
问题 I have a problem reading the configuration file (NLog.config) from my class library project when I call it from my ASP.NET MVC4 project. I tested my code using an Unit Test Project and reads the configuration file properly and makes logging correctly on the file that I specified on the NLog.config, so the NLog.config is correctly defined. I also set "Copy always" at Copy to Output Directory settings, just like the tutorial says. The problem is that when I called the class library project,

Custom target with injected services for NLog with .net core

随声附和 提交于 2019-12-12 13:07:04
问题 I'm using NLog with NLog.Extensions.Logging for aps.net core support. I need to create a custom target and inject service into the target's constructor. The following code never gets executed: public MyTarget(IService service) {....} as soon as I remove IService param, everything works. How can I inject my service into custom target? 回答1: Still not sure what is the right and proper way how to do that. For now implemented in a following way (not a good solution, but at least it works): public

Approach for tying all NLog logs back to the original request within WebAPI?

醉酒当歌 提交于 2019-12-12 13:04:16
问题 I am working to build an API using WebAPI, and have been using NLog for logging throughout the stack. My API solution has two main projects including: The website layer itself that implements the controllers and webapi stuff A service layer that implements "async" commands and handlers in a CQRS-like fashion What I'm trying to achieve is to automatically generate a unique ID that I can attach to log statements so that any logs written while servicing a single request, no matter what layer

NLog to PostgreSQL connection

故事扮演 提交于 2019-12-12 12:41:16
问题 I have a problem in connecting with the postgres database through NLog. I made the database with query: CREATE TABLE system_logging ( ID serial primary key, entered_date date default Now(), log_application varchar(200) NULL, log_date character varying(100) NULL, log_level character varying(100) NULL, log_logger character varying(8000) NULL, log_message character varying(8000) NULL, log_machine_name character varying(8000) NULL, log_user_name character varying(8000) NULL, log_call_site

NLog: logging an object serialized to JSON

冷暖自知 提交于 2019-12-12 11:21:29
问题 I have .Net project with NLog configuration which allows me to produce JSON-formatted log file. It works fine with simple text messages. Now, I need to log a number of arbitrary objects already serialized to JSON. When I log those JSON strings as log messages, NLog puts the text in quotes and subsequently escapes inner JSON syntax. This renders such output unusable. So far I have failed to find an NLog feature or layout setting that would simply dump my JSON string as a literal, without