Nlog Callsite is wrong when wrapper is used

See my answer to this question: Problem matching specific NLog logger name I have copied the example code (for an abbreviated NLog wrapper) from that answer here to save some trouble: class NLogLogger : ILogger { private NLog.Logger logger; //The Type that is passed in is ultimately the type of the current object that //Ninject … Read more

How do I not log a particular type of Exception in Logback?

You can do it with a simple EvaluatorFilter: <filter class=”ch.qos.logback.core.filter.EvaluatorFilter”> <evaluator> <expression>java.lang.RuntimeException.class.isInstance(throwable)</expression> </evaluator> <onMatch>DENY</onMatch> </filter> Please note that you need the following dependency in your pom.xml as well: <dependency> <groupId>org.codehaus.janino</groupId> <artifactId>janino</artifactId> <version>3.1.9</version> </dependency> Another possible solution is a custom Filter implementation: import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; import ch.qos.logback.classic.spi.ThrowableProxy; import ch.qos.logback.core.filter.Filter; import ch.qos.logback.core.spi.FilterReply; public class SampleFilter extends … Read more

Is there anyway to write the following as a C++ macro?

#define my_macro my_stream() class my_stream: public std::ostringstream { public: my_stream() {} ~my_stream() { ThreadSafeLogging(this->str()); } }; int main() { my_macro << 1 << “hello world” << std::endl; } A temporary of type my_stream is created, which is a subclass of ostringstream. All operations to that temporary work as they would on an ostringstream. When the … Read more

Microsoft.Extensions.Logging Vs. NLog

With NLog you could do: var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info(“Hello {Name}”, “Earth”); That works for all platforms and all frameworks. Microsoft.Extensions.Logging With .NET Core, Microsoft introduced the ILogger abstraction from Microsoft.Extensions.Logging. You could use that logging abstraction in your project and integrate it with NLog. For example in ASP.NET Core you could inject Microsoft.Extensions.Logging.ILogger<HomeController> and … Read more

How Thread-Safe is NLog?

I don’t really have an answer to your problem, but I do have some observations and some questions: According to your code, it looks like you want to create a logger per thread and you want to have that logger log to a file named for some passed-in id value. So, the logger whose id … Read more