I'm having a lot of problems with the integrated log4net logging.
I have an ASP.NET MVC 4 app that uses WCF services. Both are .NET 4.5 I'm
using version 3.1.0 of Castle Windsor.
Both my WCF service and my MVC app use an identical log4net.config file.
Both the app and WCF service installers are as so:
public class LoggerInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container,
IConfigurationStore store)
{
string bd = AppDomain.CurrentDomain.BaseDirectory;
string configFile = bd + @"\log4net.config";
container.AddFacility<LoggingFacility>(f =>
f.UseLog4Net(configFile));
}
}
Though the app and service are in different folders, in both cases,
configfile is pointing to the existing log4net.config file. As I mentioned
before, the config files are identical. The config file is as follows:
<log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="100" />
<connectionType value="System.Data.SqlClient.SqlConnection,
System.Data, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<connectionString value="data source=MYMACHINE\SQLEXPRESS;initial
catalog=GEMS;integrated security=true;persist security info=True" />
<commandText value="INSERT INTO GEMS_Log
([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date,
@thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="AdoNetAppender" />
</root>
</log4net>
The DAL layer used by my WCF service does a great deal of logging. All of
the classes in the DAL layer are generated by a template and their use of
logging is identical. Each class has public property as follows:
public ILogger Logger { get; set; }
Now, here's the problem. The logging works for some classes (but not all)
in my WCF service. The logging doesn't work at all from my MVC app. In all
cases, ILogger is from Castle.Core.Logging. In all cases, Castle appears to
be populating ILogger with a valid logger. But only some classes in my WCF
service seem to actually produce log messages and others (I've stepped over
in the debugger to make sure they're getting called) simply don't get
posted to the database. And as I said, NOTHING from my MVC app gets logged.
This is really frustrating. I'd appreciate any pointers you might provide
to help me resolve this issue.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/Mlk-7lhqyzkJ.
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.