nlog

Ninject logger using NLog

天涯浪子 提交于 2019-12-21 03:38:20
问题 I've just started learning Ninject but have come across a problem with the logger. I've currently got a controller that has a service and logger injected into the constructor like so: public ToolsController(IToolsService toolsService, ILogger logger) { logger.Info("ToolsController Created"); this.toolsService = toolsService; this.logger = logger; } The problem is on the logger.Info line (for example) in the constructor which seems to use the wrong logger, so the logger name it prints out is

NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust)

自古美人都是妖i 提交于 2019-12-20 10:37:34
问题 It seems like NLog can't use reflection for GetCurrentClassLogger() , even though my MVC 3 app is deployed in a Full Trust environment on IIS7. I'm using StructureMap 2.6.1 and the problem seems to appear sporadically between deploys. I can't figure out why, though I don't think StructureMap is causing it. Bootstrapper class: public static class Bootstrapper { public static void ConfigureStructureMap() { ObjectFactory.Initialize(Init); } private static void Init(IInitializationExpression x) {

Which is the best viewer for NLog? [closed]

試著忘記壹切 提交于 2019-12-20 10:22:30
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Which is the best viewer for NLog? log2console sentinel Other ? 回答1: Although a very old question, the same question has been haunting

How do I configure NLog to write to a database?

烂漫一生 提交于 2019-12-20 10:03:43
问题 I'm trying to get NLog to write to a database, however with my current code it throws an exception when I attempt to debug, the exception is: The type initializer for 'NotifyIcon.Program' threw an exception. my NLog configuration file code is below, as this seems to be causing the issue as it's the only code I've changed. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true"> <

NLog FileTarget wrapped with BufferingTargetWrapper fails to write log if there is a delay

戏子无情 提交于 2019-12-20 04:07:42
问题 I may have stumbled across an issue with NLog, but thought I would check here first for an answer: To recreate the issue I cloned the NLog source so I could add a delay to cause the problem. Once open in visual studio, I added a console application that references the NLog source projects and makes some very simple log calls. The NLog.config is as follows: <nlog> <targets> <target name="buffer" type="BufferingWrapper"> <target name="logfile" type="File" fileName="log.txt"/> </target> <

Redirect all NLog output to Serilog with a custom Target

别说谁变了你拦得住时间么 提交于 2019-12-20 02:14:21
问题 As a step in switching from NLog to Serilog, I want to redirect the standard wiring underlying standard invocations of NLog's LogManager.GetLogger(name) to Bridge any code logging to NLog to forward immediately to the ambient Serilog Log.Logger - i.e. I want to just one piece of config that simply forwards the message, without buffering as Log4net.Appender.Serilog does for Log4net. Can anyone concoct or point me to a canonical snippet that does this correctly and efficiently please?

《大话数据结构》读后总结(七)

穿精又带淫゛_ 提交于 2019-12-20 01:01:06
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 常见的时间复杂度 执行次数 函数阶 非正式术语 12 O(1) 常数阶 2n+3 O(n) 线性阶 3n^2+2n+1 O(n2) 平方阶 5log2n+20 O(logn) 对数阶 2n+3nlog2n+19 O(nlogn) nlogn阶 6n^3+2n^2+3n+4 O(n3) 立方阶 2^n O(2n) 指数阶 常用的时间复杂度所耗费的时间从小到大依次是 O(1)<O(logn)<O(n)<O(nlogn)<O(n2)<O(n3)<O(2n)<O(n!)<O(nn) 最坏情况与平均情况 对算法的分析,一种方法是计算所有情况的平均值,这种时间复杂度的计算方法称为平均时间复杂度。另一种方法是计算最坏情况下的时间复杂度,这种方法称为最坏时间复杂度。一般在没有特殊说明的情况下,都是指最坏时间复杂度。 空间复杂度 计算公式记作:S(n)=O(f(n)),其中,n为问题的规模,f(n)为语句关于n所占存储空间的函数。 欢迎扫描下方二维码,持续关注: 互联网工程师(id:phpstcn),我们一起学习,一起进步 来源: oschina 链接: https://my.oschina.net/u/2672664/blog/3040216

Suggest design: almost every object in app has loggger

我是研究僧i 提交于 2019-12-19 04:58:56
问题 I'm writing an application. I use NLog for logging. In this application almost every object can write to log. I define protected member for that: protected Logger logger; protected virtual Logger Logger { get { return logger ?? (logger = LogManager.GetLogger(this.GetType().ToString())); } } In that case I need to copy/paste this code for every base class in application. Or I see other option: define app-specific root object with logger in it and subclass it. But semantically this sounds wrong

Passing in the type of the declaring class for NLog using Autofac

青春壹個敷衍的年華 提交于 2019-12-19 03:37:10
问题 Following on from this question I would like autofac to inject the type of the declaring object into the constructor of my NLog service, so that it can correctly log which type is logging entries. My NLogService class looks like this... public class NLogService : ILogService { private readonly Logger _logger; public NLogService(Type t) { var consumerType = t.DeclaringType.FullName; _logger = LogManager.GetLogger(consumerType); } However it fails on app startup because it obviously cannot work

What is the best way of using NLog with MEF?

旧时模样 提交于 2019-12-18 16:59:14
问题 I am wondering what is the best way to use NLog with Managed Extensibility Framework (MEF)? I have an application that support plugins using MEF architecture (Import and Exports etc) I want to add logging capability to my application. As a logging component I want to use NLog. What would you recommend? 1. Create a wrapper for NLog, i.e. additional plugin that configures NLog and exports functions like void Log(string level, string message) that other plugins importing 2. Every plugin should