2
votes

I'm working on converting a crm 3.0 callout library, and would like to use log4net for logging. I am able to get the library to compile and deployed to my crm server, but I can't seem to get it to log. I'm using a RollingLogFileAppender. I put the log4net.config and compiled versions of the library in the \server\assembly folder. I have trace logs enabled in crm and no errors are logged here or in event viewer. I've granted full access rights to the network service user on the \server\assembly folder and this is also where I've configured the log4net logs to be written to.

When I write my own log method using StreamWriter, it does work, but I would rather use log4net.

I have a feeling that log4net cannot find the log4net.config, but I'm not sure how to determine this without going through the trouble of remote debugging or adding additional debug code to the log4net library.

Any suggestions?

1

1 Answers

1
votes

For plugins/workflow activities, your configuration file will be relative to the \Microsoft Dynamics CRM\Server\bin directory (assuming you're using a relative path). I use a single assembly for both the CRMWeb\bin and \Server\bin directories so I actually have two configuration files. One is at CRMWeb\ISV\MyISV\log4net.xml and the one for plugins/workflows is located at \Microsoft Dynamics CRM\Server\bin\ISV\MyISV\log4net.xml.

In my assemblyinfo.cs I have the following specification:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "ISV\MyISV\log4net.xml", Watch = true)]

Once you're sure that you're looking in the right place for your configuration file... If you're still having trouble with normal rolling files, set up an smtp appender to see if you get e-mails. I've found the I have very limited permissions running as plugins/workflows and don't have access to the file system. You'll want to make sure you can write to the specified directory (which it sounds like you can).

Let me know if this helps.

EDIT: My experience is with CRM 4.0, so I would adjust the paths as necessary.