I am using the WcfFacility (trunk version) for some services.
I have a ErrorHandler behavior, which uses a Logger (/exceptions.txt),
as well a component "X" which also uses a Logger (/component.txt).
The ErrorHandler behavior is applied to a group of services and the
logger must specific for this behavior, that's why must be different
than other loggers.
Now my service must use both components, the ErrorHandler behavior and
the component X. I think the design is not so weird.
Below, an example in code, about what i wanna get working in binsor:
using (_container = new WindsorContainer())
{
_container.AddFacility<WcfFacility>()
.Register(
Component.For<ILogger>().Named
("ch_logger").Instance(new Log4netFactory(_logConfigFile).Create
("lo4net.LogManager_return")),
Component.For<ILogger>().Named
("service_logger").ImplementedBy<ConsoleLogger>(),
Component.For<IComponentHandler>().Named
("logbookEntryCH").ImplementedBy<LoggerCH>()
.ServiceOverrides(
ServiceOverride.ForKey("Logger").Eq
("ch_logger")
),
Component.For<IServiceBehavior>
().ImplementedBy<ServiceMetadataBehavior>()
.Parameters(
Parameter.ForKey("HttpGetEnabled").Eq
("true"),
Parameter.ForKey("HttpGetUrl").Eq
(_baseAddress)
),
Component.For<IServiceBehavior>
().ImplementedBy<InternalErrorHandlerSB>()
.ServiceOverrides(
ServiceOverride.ForKey("Logger").Eq
("service_logger")
),
Component.For<IEx1Contract>
().ImplementedBy<Ex1Service>()
.ServiceOverrides(
ServiceOverride.ForKey("Logger").Eq
("service_logger")
)
.ActAs(
new DefaultServiceModel()
.AddEndpoints(
WcfEndpoint
.BoundTo(_binding)
.At(_endpointAddress1)
)
)
);
assertDifferentLoggers();
}
Regards
Pepe
This behavior is applied to the service.
On 13 Dec, 21:03, Jason Meckley <[email protected]> wrote:
> Why would you need more than 1 logger per component? if you need to
> log to multiple locations: database, text file, email, MSMQ, etc. you
> can setup multiple appenders in the log4net configs and then
> configure
> 1. a default logger
> 2. loggers specific to individual components
>
> That way you only need one instance of the logger.
>
> On Dec 12, 7:15 pm, ppcanodehuelva <[email protected]> wrote:
>
> > Hi all,
>
> > I want to have 2 or more loggers in the same container, in order
> > different components in the same container can be configured with
> > different loggers. It MUST be made via binsor or xml.
>
> > In code works like:
>
> > .Register(
> > Component.For<ILogger>().Named("ch_logger").Instance(new Log4netFactory
> > (_logConfigFile).Create("lo4net.LogManager_return")),
> > Component.For<ILogger>().Named
> > ("service_logger").ImplementedBy<ConsoleLogger>()
> > );
>
> > Unfortunately, the following problems come out via binsor or xml:
>
> > 1° I cannot register the Log4netLogger in the container, because the
> > ILogger, Log4netFactory properties are required to be activated for
> > the container and i have no idea how to get the ILogger property.
>
> > public Log4netLogger(ILogger logger, Log4netFactory factory)
> > {
> > Logger = logger;
> > Factory = factory;
> > }
>
> > 2° I don´t know exactly whether there is a way to call the Instance
> > method of the Component from castle xml configuration files or binsor
> > (i could not do it)
>
> > 3° I was trying to get it working with the SupportFacility, but as
> > shown below, exception comes out. You could see it in the
> > forum:http://forum.castleproject.org/viewtopic.php?p=14536#14536
>
> > facility FactorySupportFacility
> > component 'log4netfactory', ILoggerFactory, Log4netFactory:
> > configFile = 'MYPATH\\config2.log4net'
> > component 'ch_logger', ILogger, Log4netLogger:
> > �...@factoryid='log4netfactory'
> > �...@factorycreate='Create'
> > parameters:
> > name='egal'
>
> > 4° It could be made via child container, but it is highly disallowed
> > because it makes the container configuration more complex, as many new
> > loggers are inserted.
>
> > I didn't find any examples or hints how to do that, at this moment, i
> > cannot figure out how to get it working.
>
> > Thanks and regards.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---