Hello All,
I've tried to use NLog with silverlight. This works with some minor
(IMHO) changes (see below) to allow creating a NLogFactory with a
Configuration instead of config file (as reading file is not supported
in silverlight). If this change is not to big, risky or plain wrong,
could it be incorperated in v3 ?
Kind regards,
Marwijn.
In NLogFactory (probably same/similair change should be made in the
extended nlog factory):
Added additional constructor:
public MyNLogFactory(LoggingConfiguration configuration)
{
LogManager.Configuration = configuration;
}
in LoggingFacility:
Added
private ILoggerFactory loggerFactory;
public MyLoggingFacility
LogUsing<TCustomLoggerFactory>(TCustomLoggerFactory loggerFactory)
where TCustomLoggerFactory : ILoggerFactory
{
loggerImplementation = LoggerImplementation.Custom;
this.loggerFactory = loggerFactory;
return this;
}
Changed
protected override void Init()
{
SetUpTypeConverter();
if (loggerFactory == null) // Added null check to see the
user has provided it's own LoggerFactory
{
loggerFactory =
ReadConfigurationAndCreateLoggerFactory();
}
RegisterLoggerFactory(loggerFactory);
RegisterDefaultILogger(loggerFactory);
RegisterSubResolver(loggerFactory);
}
Usage example:
LoggingConfiguration config = new LoggingConfiguration();
var debugTarget = new NLog.Targets.
config.AddTarget("console", debugTarget);
config.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info,
debugTarget));
var logFactory = new NLogFactory(config);
var logger = logFactory.Create("Bootstrapper");
_container.AddFacility(new LoggingFacility().LogUsing(logFactory));
--
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" 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-devel?hl=en.