Some snippet below:
protected void Application_Start(object sender, EventArgs e)
{
XmlConfigurator.Configure();
log4net.Repository.ILoggerRepository repo = LogManager.GetRepository();
foreach (log4net.Appender.IAppender appender in repo.GetAppenders())
{
if (appender.Name.CompareTo("RollingFileAppender") == 0 && appender is log4net.Appender.RollingFileAppender)
{
var appndr = appender as log4net.Appender.RollingFileAppender;
string logPath = "MyApplication.log";
appndr.File = logPath;
appndr.ActivateOptions();
}
}
logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
var configSource = new XmlConfigurationSource(ActiveRecordConfigStream);
Assembly assy = typeof([ParentAssembly]).Assembly;
ActiveRecordStarter.Initialize(configSource, assy.GetTypes());
logger.Info("My Application Starting...");
}
1 comment:
The actual xml consumed by XmlConfigurationSource is:
<activerecord isWeb="true" threadinfotype="Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeInfo, Castle.ActiveRecord"><config><add key="SessionScopeWebModule" value="Castle.ActiveRecord.Framework.SessionScopeWebModule" /><add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" /><add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" /><add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" /><add key="hibernate.connection.connection_string" value="Data Source=.\QMS;Initial Catalog=HealthCheckFocus;Integrated Security=true" /></config></activerecord>
Post a Comment