You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Christopher Quest <ch...@herbertgroup.com> on 2006/04/03 17:43:12 UTC
Class Library Logging
Hi,
I am using V1.2.0-beta8, on a test .DLL written in C# against .NET1.1 with
the DLL being called from a C# windows application.
I have this attribute in the the Assemblyinfo.cs file:
[assembly:
DOMConfiguratorAttribute(ConfigFile="UIFeasibility.log.config",Watch=true)]
I am setting up the logger as follows:
private static readonly ILog log =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().Declari
ngType);
Then using the logger as normal:
if (log.IsDebugEnabled) log.Debug("Constructor called");
This is my configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<logger name="UIFeasibility" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="FileAppender" />
</logger>
<root>
<level value="DEBUG" />
</root>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="Log-file.txt"/>
<appendToFile value="true"/>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="INFO"/>
<levelMax value="FATAL"/>
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger -
%message%newline" />
</layout>
</appender>
</log4net>
When the class library is accessed all of the log statments are executed but
after the windows application is closed down there is not text in the log
file even though it is created if it doesn't exists. This mechanism has
perviously worked on a windows service.
Re: Class Library Logging
Posted by Matthew Brown <oc...@gmail.com>.
Is there a reason why there are no appender-ref's in the root element? I
would start there...
I think the next step someone would ask is if you see anything using the
internal log4net logging.
On 4/3/06, Christopher Quest <ch...@herbertgroup.com> wrote:
>
> Hi,
>
> I am using V1.2.0-beta8, on a test .DLL written in C# against .NET1.1 with
> the DLL being called from a C# windows application.
>
> I have this attribute in the the Assemblyinfo.cs file:
>
> [assembly: DOMConfiguratorAttribute(ConfigFile="UIFeasibility.log.config
> ",Watch=true)]
>
> I am setting up the logger as follows:
>
> private static readonly ILog log = LogManager.GetLogger(
> System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
>
> Then using the logger as normal:
>
> if (log.IsDebugEnabled) log.Debug("Constructor called");
>
> This is my configuration file:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <log4net>
> <logger name="UIFeasibility" additivity="false">
> <level value="DEBUG"/>
> <appender-ref ref="FileAppender" />
> </logger>
>
> <root>
> <level value="DEBUG" />
> </root>
>
> <appender name="FileAppender" type="log4net.Appender.FileAppender
> ">
> <file value="Log-file.txt"/>
> <appendToFile value="true"/>
> <filter type="log4net.Filter.LevelRangeFilter">
> <levelMin value="INFO"/>
> <levelMax value="FATAL"/>
> </filter>
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%date %-5level %logger
> - %message%newline" />
> </layout>
> </appender>
>
> </log4net>
>
> When the class library is accessed all of the log statments are executed
> but after the windows application is closed down there is not text in the
> log file even though it is created if it doesn't exists. This mechanism has
> perviously worked on a windows service.
>