You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/02/27 18:50:24 UTC
[GitHub] [logging-log4net] tschettler opened a new pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
tschettler opened a new pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73
This refactors type activation into an `ActivationProvider` class, which provides wrapper methods for the `IActivator` interface. The default `IActivator` implementation (`DefaultActivator`) derives from the current logic which uses `Activator.CreateInstance`. Clients of log4net can set the IActivator instance to a custom implementation if they so choose. For an example use case, this will allow for dependency injection in custom appenders and pattern converters.
I researched how to do dependency injection in custom log4net appenders and pattern converters without making changes to log4net itself and it proves to be increasingly difficult, since it would require custom classes in cases where Activator.CreateInstance is used. I tried to keep my changes to a bare minimum, as I recognize this project is one of the most popular logging frameworks in .NET and any changes must be heavily scrutinized.
I also recognize that there have been other attempts to add this capability to log4net (#26, #72), but this implementation is merely a refactoring of the existing `Activator.CreateInstance` logic. With all due respect to the authors of the previous implementation attempts, this implementation provides one other key component that the other attempts were missing. The `IsTypeConstructible` method of `XmlHierarchyConfigurator` has been refactored into a `CanCreateInstance` method on the `IActivator` interface. This is necessary to allow custom activation of types without default constructors.
Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts closed pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts closed pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-955657755
@tschettler I think next steps would be to raise a PR with a mvp implmentation of the described pattern in log4net. I don't know when I'll get time to look at an implementation, so if you want to crack on, go for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-957005054
Sounds good, I’d be up for that, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts closed pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts closed pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-957005054
Sounds good, I’d be up for that, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-953506178
You are correct, due to the way types are instantiated in log4net, using a service locator is the way I would do this now. However, when I mention "DI", I'm not referring to a service locator per se. I'm rather referring to the dependency inversion principle, where the dependencies for a class are provided instead of having to "new" them up and tightly couple low level modules and higher level modules. The service locator is a means to this end, and unfortunately, one of the only (if not, the only) means when attempting to use dependency inversion with log4net.
To decouple high level and low level modules with no changes to log4net, the consuming application must expose some sort of `GetService` method from the composition root, consequently encouraging the use of the service locator pattern when working with log4net, if one wishes to use dependency inversion. This exposed service locator would then be referenced from say a custom pattern converter to pull in the necessary dependency within its implementation and not as an injected dependency.
I agree with your sentiment on the service locator pattern, it should be avoided when possible. However, if one wants to achieve loose coupling within custom log4net components, service locator is the only option that I see. I think it would be amazing if log4net would "buy into the DI system from the get-go", but the changes this would require are much more significant and far reaching in my opinion. Unless/Until that happens, as it is right now, service locator in one shape or another is the only real option. The benefit of allowing a very constrained service locator within log4net is that it would encourage developers to use proper dependency injection when utilizing log4net, rather than requiring the use of the service locator pattern to achieve the same results.
Presently, with service locator:
```cs
public class Program {
// the developer needs to expose the service locator in order to allow the component to resolve dependencies.
public static IServiceLocator ServiceLocator = Container.GetServiceResolver();
}
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
private IHttpContextAccessor _httpContextAccessor;
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
if (_httpContextAccessor == null) {
_httpContextAccessor = Program.ServiceLocator.GetService<IHttpContextAccessor> ();
}
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
```
Note that this also violates SRP since the code also requires logic to retrieve its own dependencies.
By allowing for dependency inversion, the same pattern layout converter can now have dependencies injected, as the service locator logic is confined to an implementation provided to log4net (as per this PR):
```cs
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
public HttpContextPatternLayoutConverter (IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
}
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler edited a comment on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler edited a comment on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-953506178
@fluffynuts you are correct, due to the way types are instantiated in log4net, using a service locator is the way I would do this now. However, when I mention "DI", I'm not referring to a service locator per se. I'm rather referring to the dependency inversion principle, where the dependencies for a class are provided instead of having to "new" them up and tightly couple low level modules and higher level modules. The service locator is a means to this end, and unfortunately, one of the only (if not, the only) means when attempting to use dependency inversion with log4net.
To decouple high level and low level modules with no changes to log4net, the consuming application must expose some sort of `GetService` method from the composition root, consequently encouraging the use of the service locator pattern when working with log4net, if one wishes to use dependency inversion. This exposed service locator would then be referenced from say a custom pattern converter to pull in the necessary dependency within its implementation and not as an injected dependency.
I agree with your sentiment on the service locator pattern, it should be avoided when possible. However, if one wants to achieve loose coupling within custom log4net components, service locator is the only option that I see. I think it would be amazing if log4net would "buy into the DI system from the get-go", but the changes this would require are much more significant and far reaching in my opinion. Unless/Until that happens, as it is right now, service locator in one shape or another is the only real option. The benefit of allowing a very constrained service locator within log4net is that it would encourage developers to use proper dependency injection when utilizing log4net, rather than requiring the use of the service locator pattern to achieve the same results.
Presently, with service locator:
```cs
public class Program {
// the developer needs to expose the service locator in order to allow the component to resolve dependencies.
public static IServiceLocator ServiceLocator = Container.GetServiceResolver();
}
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
private IHttpContextAccessor _httpContextAccessor;
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
if (_httpContextAccessor == null) {
_httpContextAccessor = Program.ServiceLocator.GetService<IHttpContextAccessor> ();
}
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
```
Note that this also violates SRP since the code also requires logic to retrieve its own dependencies.
By allowing for dependency inversion, the same pattern layout converter can now have dependencies injected, as the service locator logic is confined to an implementation provided to log4net (as per this PR):
```cs
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
public HttpContextPatternLayoutConverter (IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
}
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-953642068
@tschettler thanks for the response and the thorough code example. The example does, however, back up exactly what my thoughts are on the whole story: the ultimate result is simply that service location is pushed out of _your_ code into _log4net's_ code. This means that people who want this get a cleanup at the cost of every other log4net user - log4net is used in a wide array of places, so I have to apply very cautious reasoning when examining requests like this.
The fact is that, somewhere, something is doing a `ServiceLocator.Resolve<T>` for the more complex `T` (in this case, your `HttpContextPatternLayoutConverter`. There are alternative ways to accomplish what you want without introducing the complexity and potential security holes of being able to push an outside-in service-locator into log4net.
For example:
```csharp
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
public HttpContextPatternLayoutConverter(): this(Container.Resolve<IHttpContextAccessor>())
{
}
public HttpContextPatternLayoutConverter (IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
}
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
```
I hear you saying "but the point is to not have service-locator in my code!" and yes, this means that you have service-locator in your code - this is a very small step up from "poor man's DI" which I used a very, very long time ago to get older mvc controllers testable before figuring out the correct way to do DI.
you could also have:
```csharp
public class HttpContextPatternLayoutConverterFacade: PatternLayoutConverter
{
private HttpContextPatternLayoutConverter _actual;
public HttpContextPatternLayoutConverterFacade()
{
// this is pretty-much the code proposed to live within log4net
_actual = GlobalContainer.Resolve<HttpContextPatternLayoutConverter>();
}
public override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
_actual.Convert(writer, loggingEvent);
}
}
```
The above is what I meant by achieving the same goals in user-land. Remember: there are _many, many_ consumers of `log4net`, and many of them have no need whatsoever for IOC, but all would have to take on the potential worry that a third-party dependency could gain unnecessary privilege in their system.
I think that a better solution, might be for log4net to have "proper" DI and expose an api like Serilog does - one that's very familiar from use of DI frameworks that I've dealt with (I haven't collected 'em all, but I have worked a lot with Castle.Windsor, StructureMap and DryIOC, and a bit with Autofac and, back in the mists of time, unity):
Instead of allowing the hosting application to completely take over how all things are constructed, log4net could:
- expose factory functions for those services
- scan constructors of types it's about to create to match up with factories or simply new them up
This is the absolute lowest-level DI I can imagine, where lifespan is controlled by the logic within the factory function. The second part - constructing items within log4net-land - isn't so difficult.
Imagineered code:
```csharp
using log4net.DependencyInjection;
namespace YourApplication.IOC
{
public class Bootstrapper
{
public static void Bootstrap()
{
var container = new WhateverContainerYouLikeToUse();
// all your existing logic still happens here
// transient registration, or simply relying on whatever lifespan you've
// registered with in your container:
Log4NetContainer.Instance.Register(container.Resolve<TService>);
// singleton, irrespective of container
var singleton = container.Resolve<TService2>();
Log4NetContainer.Instance.Register(() => singleton);
}
}
}
```
of course, the bare-minimum factory method exposure could be extended to provide friendlier methods:
```csharp
Log4NetContainer.Instance.Register(singleton);
// parameterless constructor, service -> impl
Log4NetContainer.Instance.Register<TService3, TImplementation3>();
```
or even to do magic like scans with 1-1 mappings being automatically resolved within a configured assembly, but now we're stepping out of bare-bones and into nice-to-have and perhaps it's best to start with the minimum viable product?
Now, I know that this also exposes the ability of a third-party to change how services are constructed, but it makes it considerably harder to do something unexpected / nefarious because the third-party now has to know about types in _your_ system.
Thoughts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-952597091
@tschettler before moving forward with any changes to log4net, I'd ask that you try to achieve these goals in user-land (ie, not in log4net, but in the consuming project). The term "DI" is being used here, but it's more like service-locator, which can be accomplished anywhere. True DI would require that log4net buy into the DI system from the get-go.
IOW, I'm still not absolutely convinced of the need, and since I don't see it, I'm asking you to provide a comparison between how what you want would currently be accomplished (as I'm sure it is being accomplished already) vs the change in user-land code if log4net had this mechanism.
The most secure code is none at all. Before embarking on a best-effort to make the code secure, I'd like to see how the changes potentially make life better for the consumer. I'm not asking out of obtuseness, but rather out of an abundance of caution seasoned with a sprinkling of curiousity.
Just because I don't understand a position, it doesn't make that position invalid - it may just mean that I need to learn more. I'm a huge fan of DI, done correctly, and majorly cautious of service-locator, having seen the obscure spaghetti the pattern produces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-954420832
@fluffynuts thanks again for the response and great idea!
I think we are in agreement. I like the idea of log4net having its own container, and allowing services to be registered within that container. I agree that a minimalist approach is probably best to start. I think the risks you mentioned are effectively mitigated with this approach and, if implemented correctly, third parties will not really be able to change how services are constructed since that would all be either in the "user-land" or within log4net. They could add service registrations of their own, but if they are not dependencies within an expected type registered with log4net, log4net would never construct them.
I see this type of factory method as highly desirable:
```cs
Log4NetContainer.Instance.Register<IService>(() => container.Resolve<IService>());
```
In my opinion, this factory approach will probably be the most beneficial, and with the aim to provide a minimalist implementation, it would be less impactful to just support transient or singleton scoped instances from the start. Dealing with scoped services can (as you know) much more easily lead to captive dependencies without providing some sort of service lifetime indicator to log4net. This would then require log4net to create new instances of types when a scoped service has been disposed and the higher level service is to be executed again.
This conversation has evolved beyond the scope of this PR. What do you see as the next steps?
Thanks!
Travis
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-951019204
Thank you for the feedback @fluffynuts!
I understand your security concerns and completely agree with you. My initial commit was just to provide a standard way to create instances, without regard to whether they _needed_ to be created using a custom activator. I think the changes could be pared down based on your feedback and additional changes could be made to circumvent the security concerns you have outlined. Here are the following two areas that I think would cover most use cases:
1. **A DI-enabled Appender.**
One scenario here would be when someone would like to use a managed ORM to log to a database. An existing DI container manages the scope and creation of these dependencies, possibly because all data access for an application needs to be configured and managed in a specific manner. Enabling this would just require the change within `XmlHierarchyConfigurator`.
2. **A DI-enabled Pattern Converter.**
Consider wanting to use a pattern converter to log items from the HttpContext in ASP.NET Core. A standard method to retrieve HttpContext information is to inject `IHttpContextAccessor`. `ConverterInfo` only provides the converter type and there's no way to intercept the creation of the pattern converter to provide this dependency. Enabling this would just require the change within `PatternParser`.
Along with limiting the scope of changes to just be for these two classes, the `IActivator` implementation type could be registered with the log4net config and `ActivatorProvider` could perform a validation check against this type to ensure it matches. Once the instance is set, it could also protect the instance from being changed to something else.
If you would allow me, I can build out the changes as specified. With consideration to reducing the changes to account for just these scenarios, implementing some additional logic for validating the activator instance type, and locking down from further changes, what remaining security concerns would you have?
Thanks!
Travis
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts closed pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts closed pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler edited a comment on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler edited a comment on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-953506178
@fluffynuts you are correct, due to the way types are instantiated in log4net, using a service locator is the way I would do this now. However, when I mention "DI", I'm not referring to a service locator per se. I'm rather referring to the dependency inversion principle, where the dependencies for a class are provided instead of having to "new" them up and tightly couple low level modules and higher level modules. The service locator is a means to this end, and unfortunately, one of the only (if not, the only) means when attempting to use dependency inversion with log4net.
To decouple high level and low level modules with no changes to log4net, the consuming application must expose some sort of `GetService` method from the composition root, consequently encouraging the use of the service locator pattern when working with log4net, if one wishes to use dependency inversion. This exposed service locator would then be referenced from say a custom pattern converter to pull in the necessary dependency within its implementation and not as an injected dependency.
I agree with your sentiment on the service locator pattern, it should be avoided when possible. However, if one wants to achieve loose coupling within custom log4net components, service locator is the only option that I see. I think it would be amazing if log4net would "buy into the DI system from the get-go", but the changes this would require are much more significant and far reaching in my opinion. Unless/Until that happens, as it is right now, service locator in one shape or another is the only real option. The benefit of allowing a very constrained service locator within log4net is that it would - with minimal changes - encourage developers to use proper dependency injection when utilizing log4net, rather than requiring the use of the service locator pattern to achieve the same results.
Presently, with service locator:
```cs
public class Program {
// the developer needs to expose the service locator in order to allow the component to resolve dependencies.
public static IServiceLocator ServiceLocator = Container.GetServiceResolver();
}
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
private IHttpContextAccessor _httpContextAccessor;
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
if (_httpContextAccessor == null) {
_httpContextAccessor = Program.ServiceLocator.GetService<IHttpContextAccessor> ();
}
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
```
Note that this also violates SRP since the code also requires logic to retrieve its own dependencies.
By allowing for dependency inversion, the same pattern layout converter can now have dependencies injected, as the service locator logic is confined to an implementation provided to log4net (as per this PR):
```cs
public class HttpContextPatternLayoutConverter : PatternLayoutConverter {
public HttpContextPatternLayoutConverter (IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
}
protected override void Convert (TextWriter writer, LoggingEvent loggingEvent) {
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) {
writer.Write (SystemInfo.NotAvailableText);
} else {
Convert (writer, loggingEvent, httpContext);
}
}
...
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] tschettler commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
tschettler commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-957005054
Sounds good, I’d be up for that, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4net] fluffynuts commented on pull request #73: adds ActivatorProvider to allow custom type activation (Resolves LOG4NET-565)
Posted by GitBox <gi...@apache.org>.
fluffynuts commented on pull request #73:
URL: https://github.com/apache/logging-log4net/pull/73#issuecomment-950939434
Hi @tschettler
As discussed in #72, I still can't see the absolute necessity for providing externally-controlled DI (more like service-locator, to be honest) to log4net; indeed, it provides a mechanism for untrusted third-party code to inject it's own logic: once there is a statically-available method for overriding how plugins are created, one of your nuget libraries could use this mechanism to hijack control of your application, without your permission or knowledge. It is (imo) a security risk, at least on par with the XML entities security issue fixed some time back.
Plugins you write are completely under your control - so provide a parameterless constructor and use your own DI mechanisms to call into the constructor expecting dependencies to be injected via parameter. It's about the same amount of work as configuring this method but doesn't expose a well-known point of configuration which can be manipulated against you.
I also don't see the value in providing this mechanism for ADO.NET connections either - they are parameterless (unless there's one I'm missing? And even so, one could create one's own parameterless wrapper for a third-party ADO.NET connection type and configure that to be used within log4net). Exposing this functionality provides someone with a hook-point to read your database credentials!
I'd need to see an exact use-case where missing this feature is a show-stopper. So far, I can't think of one, but that doesn't mean it doesn't exist. I'm very reticent to merge in anything which can potentially be used against consumers of this library.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org