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 Michael Roberts <mi...@gmail.com> on 2010/06/25 15:22:38 UTC

WAS-hosted WCF service: log4net not writing to log file?

I have a WCF service library that is configured to use log4net 1.2.10.0
(XmlConfigurator attribute has ConfigFile="log4net.config"and Watch=true).
Inside of log4net.config, I have a RollingFileAppender set up to write to
".\logs\service.log."  Root / Level / Value = "DEBUG."

When the parent context is NUnit or WcfServiceHost, everything works fine,
but when I host the service in WAS, log4net doesn't write to the log file.
The gist of the situation is that, when the service is hosted in WAS, the
logger does not get wired up properly for some reason.


Context:

I have three NUnit scenarios, one for testing the service when it's hosted
locally, one for when it's not hosted, and one for when it's hosted on WAS.
The test project does not have any log4net configuration/attribution.

The first launches WcfServiceHost to host the service, then tests the
operations on the hosted service, and the log file gets written to the
\bin\debug folder of the test project.  The log file includes the logging
output of the service.

The second simply tests the operations of the service, and the log file gets
written in the \bin\debug folder of the test project.  The log file includes
the logging output of the service.

The third tests the service when it's hosted on WAS on an integration
server.  The log file does *not* get written.  The service works fine and no
log4net errors occur.  Even if I enable tracing, I don't see any errors.
To deploy the project, I simply copy the bin\debug files to the mapped
directory on the WAS server under \bin, then write the web.config file
(which has no references to log4net) one level above the \bin folder.  The
service binaries, log4net.dll, and log4net.config are all in the same folder
(\bin).  I've completely opened up security so that there's no question
regarding permissions.  I've run ProcMon while the service is executing, and
I do not see any errors, let alone, any denied writes.  The binary and
configuration files are identical to those that are working on the local
machine.

I changed the service code to throw a FaultException and return the status
of the logger.  _logger.IsDebugEnabled = false.  _logger.IsInfoEnabled =
false.  _logger.Logger =
log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl.


Questions:

Is there anything different about the execution context of services hosted
on WAS that might prevent log4net from working correctly?

The 32 bit DLL we're using was downloaded from the log4net distribution, but
WAS is running on 64b W2K8 and hosting the service in 32b mode.  The service
and every other 32b DLL we use are working fine.  Only logging is not
working.  (We cannot acquire the log4net source or switch to a newer version
of log4net for several months for policy reasons which are not relevant to
this issue.)

The source, including configuration, is covered by an NDA and cannot be
posted.

Any ideas?


Thanks!