Hi Ken,
I am using .NET 1.1 but I don't think that there are any major
differnces.
My appender simply looks like:
<appender name="LogFileAppender"
type="log4net.Appender.FileAppender">
<file value="${TMP}\myLogFile.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern
value="%date{yyyy-MM-dd HH:mm:ss} [%-5level] [%thread] [%logger]
%message%newline%exception" />
</layout>
</appender>
But most important: you have to make sure, that your application has
write access to the folder where the log-file should be placed! In my
first test with a .NET remoting service hosted by IIS I told the
appender simply the file name without any folder reference. The IIS was
configured to grant write access to the application.
You also have to make sure that log4net is properly configured (see the
attached answer to 'RE: Log4net with .net 2.0 for com+
servicedcomponent' which was posted to this list some weeks ago). Why?
Because you cannot configure the executing application (which is IIS) -
you have to configure your DLL instead!
Regards,
Michael
_______________________________________
DATATRAK Deutschland GmbH
Michael Hinkel
Software Developer
Rochusstrasse 65
53123 Bonn
Tel +49 (228) 97983-602
Fax +49 (228) 97983-34
[EMAIL PROTECTED]
http://www.datatrak.net
--- Begin Message ---
Thomas,
I've successfully set up log4net logging for a serviced component which
is hosted inside the IIS (.NET remoting service) using .NET 1.1.
To do this, the application (e.g. IIS) has to have write access to the
folder where the log file is to be created (this seems to be okay in
your setting).
Next, I've added the following log4net declaration in one class (e.g. a
base class of a class hierarchy) of each project which should use
log4net:
[assembly: log4net.Config.Repository("Server")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile="Web.config")]
The repository name should be the name of the assembly - but if you use
several projects and therefore have several assemblies you have to use
the same repository name in each project (at least I needed to do this,
because otherwise only one assembly was able to successfully use
log4net, and the other silently failed).
You also have to find out the root folder of your component, which
depends on the application that uses your component.
Hope this information is not completely wrong and might be of any help
to you...
Michael
_______________________________________
DATATRAK Deutschland GmbH
Michael Hinkel
Software Developer
Rochusstrasse 65
53123 Bonn
Tel +49 (228) 97983-602
Fax +49 (228) 97983-34
[EMAIL PROTECTED]
http://www.datatrak.net <http://www.datatrak.net/>
________________________________
From: Thomas, Cord [mailto:[EMAIL PROTECTED]
Sent: Monday, March 06, 2006 10:36 PM
To: [email protected]
Subject: Log4net with .net 2.0 for com+ servicedcomponent
I have a working c# exchange event sink (serviced component) that will
do things like autoaccept, log message activities in a database and
route messages. I wanted to use log4net with this but am having
problems
The core problem is that i am not getting any log messages (though i
tried various configurations)
log4net compiled from source in .net using NET_2_0 compile directive
Again, my component is doing work - and i can use a FileStream to write
to the ..\logs\CurrentLog directory - but not log4net - so, the
component has write access...
I am now going to try the log4net internal debugging - but wondered if i
had anything fundamentally wrong. Below are my config and code
AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config",
Watch = true)]
EventSink.cs
using log4net
using log4net.Config
...
private static readonly ILog log =
LogManager.GetLogger(typeof(ExchEventSink));
...
OnSave()
log.Debug("Some debug message");
// also tried adding various entries of
XmlConfigurator.Configure with no luck
Log4Net.config
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
<file value="..\\logs\\CurrentLog" />
<appendToFile value="true" />
<datePattern value="yyyyMMdd" />
<rollingStyle value="Date" />
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true" />
<levelMin value="DEBUG" />
<levelMax value="FATAL" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M -
%m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
............................................................
Cord Thomas
Information Services and Technology (IST)
RAND
1776 Main Street
Santa Monica CA 90407
Phone: 310.393.0411 x6672
e-mail: [EMAIL PROTECTED]
________________________________
This email message is for the sole use of the intended recipient(s) and
may contain privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.
________________________________
--- End Message ---