Search code examples
wcflog4netwcf-binding

log4net stuck & WCF


I am using log4net in an enterprise system, the system have three tiers:

  1. API
  2. Internal Notifications
  3. Integration to 3rd party: External Notifications

The layers talk each other via WCF (wsHttpBinding) and in each layer there is a log file. When I run a test workflow, each tier executed his job but the logger did not write anything.

Any ideas?


Solution

  • Here are a few ideas:

    1. In each tier, do you have a call to log4net.Config.XmlConfigurator.Configure(...)? In most cases, people use an assembly attribute to do this in the AssemblyInfo.cs/Program.cs/Global.asax.cs/etc. but you can also just call it somewhere in your application startup routine. See this page ("When should I log my first message"): http://logging.apache.org/log4net/release/faq.html

    2. If you are using file-based logging, where are you trying to store the log files? - does the target directory exist, and does the user account that is running the tier have write permission to that folder? For web apps, the user account is the App Pool identity, and for Windows Services, the user account is the Login that runs the service. For console and windows apps, the user account may be the user that launches the app.

    If all else fails you can turn on log4net internal debugging which might help: http://logging.apache.org/log4net/release/faq.html ("How do I enable log4net internal debugging")