log4net logging
Brought to you by:
sdouglas50,
whitedog12
Instead of the EntLib logging that is now implemented
it schould be better to include the log4net as default
logger class. Because the Hapi projects uses the
"Jakarta Commons Logging (JCL)" logging framework with
the underlaying log4J toolkit.
I supplied a log4netLogger class:
You also need to modify the LogFactory class:
class LogFactory
{
public static Log getLog(System.Type classType)
{
//return new EntLibLogger();
return new
log4netLogger(log4net.LogManager.GetLogger(classType));
}
public static Log getLog(System.String name)
{
//return new EntLibLogger();
return new
log4netLogger(log4net.LogManager.GetLogger(name));
}
}
Dont forget to reference the log4net.dll assembly to
the project!
log4netLogger class
Logged In: NO
To enable log4net in a project or a Nunit test add
log4net.Config.XmlConfigurator.Configure()
to your code!
And modify your app.config file to something like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net" />
</configSections>
<log4net>
<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level
%logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
</configuration>
for more information see http://logging.apache.org/log4net/
Logged In: YES
user_id=1522633
I'm not sure how other people feel about this, but Bob and I
talked about not coupling the logging to either log4net or
the enterprise logging library. We decided that we should
use the System.Diagnostics instead of any specific logging
library. Currently, the 1.1 nHapi uses the
System.Diagnostics to write all logging to.