Custom logging inside a Extention-rule

Hi,

I'm trying to enable some custom logging inside my extention rules. After a ot of search I decided to ask you if it's possible or not.

For the time beeing I've tryed to approaches:

1. Add a reference to Logging.dll and then try to use the code:

using Microsoft.MetadirectoryServices.Logging;
Log("message", true, 2);

2. Import a log4net dll into my project, add the configuration to the app.config file.

None of then seams to work... The log4net.dll doesn't show me the log methods, and with the logging.dll I have the error

 'Microsoft.MetadirectoryServices.Logging.Logging.Log(string, bool, int)' is a 'method' but is used like a 'type'

Is it possible to do some custom log with FIM 2010?

Thanks in advance for your help,

Marc

July 6th, 2015 9:55am

Hello,

sure you can, did that a lot of times.

I can see from the path in the Namespace you should use:

Logging.Log("message", true, 2)

I assume you had configured a proper logging.XML for the logging.dll ?

should go like this:

<?xml version="1.0" encoding="utf-16" ?>
<rules-extension-properties>
     <logging>
          <use-single-log>false</use-single-log>
          <file-name>sync.log</file-name>
          <logging-level>2</logging-level>
     </logging>
</rules-extension-properties> 

/Peter

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 11:15am

This is simple .NET logging. You can simply use a Log method and call it.  
July 6th, 2015 11:16am

Thanks for the answer.


In fact my logging.xml looks like :

<rules-extension-properties>
	<logging>
        	<use-single-log>false</use-single-log>
        	<file-name>galsync.log</file-name>
        	<logging-level>0</logging-level>
	</logging>
</rules-extension-properties>

And When I try to do

using Microsoft.MetadirectoryServices.Logging;

namespace Mms_Metaverse
{
    public class MVExtensionObject : IMVSynchronization
    {       
        Logging.Log("message", true, 2);
        ...
    }
}

I'm getting the error messages

  • Invalid token '(' in class, struct, or interface member declaration    D:\ExtensionFIM\MVExtension\MVExtension.cs
  • 'Microsoft.MetadirectoryServices.Logging.Logging.Log(string, bool, int)' is a 'method' but is used like a 'type'    D:\ExtensionFIM\MVExtension\MVExtension.cs

in the "Log(" method...



  • Edited by Marc_27 23 hours 24 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 3:51am

Hi,

I can't see an error in how you are using this, but I'm not the greatest developer on earth ;-)
Your implementation Looks like mine.

Anyone else a Suggestion ?

/Peter

July 7th, 2015 4:50am

I just found it :)

My command Logging.Log was outside any method, now the errors are gonne

  • Marked as answer by Marc_27 22 hours 0 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 5:14am

Thanks for the answer.


In fact my logging.xml looks like :

<rules-extension-properties>
	<logging>
        	<use-single-log>false</use-single-log>
        	<file-name>galsync.log</file-name>
        	<logging-level>0</logging-level>
	</logging>
</rules-extension-properties>

And When I try to do

using Microsoft.MetadirectoryServices.Logging;

namespace Mms_Metaverse
{
    public class MVExtensionObject : IMVSynchronization
    {       
        Logging.Log("message", true, 2);
        ...
    }
}

I'm getting the error messages

  • Invalid token '(' in class, struct, or interface member declaration    D:\ExtensionFIM\MVExtension\MVExtension.cs
  • 'Microsoft.MetadirectoryServices.Logging.Logging.Log(string, bool, int)' is a 'method' but is used like a 'type'    D:\ExtensionFIM\MVExtension\MVExtension.cs

in the "Log(" method...



  • Edited by Marc_27 Tuesday, July 07, 2015 8:00 AM
July 7th, 2015 7:49am

I just found it :)

My command Logging.Log was outside any method, now the errors are gonne

  • Marked as answer by Marc_27 Tuesday, July 07, 2015 9:24 AM
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 9:12am

Hi Peter,

I'm trying to do some tests, where are the log files created?

I can't find it...

Thanks in advance,

Marc

July 8th, 2015 7:49am

Hello,

you should find the logfile in the MaData Folder under your FIM Install Path.

/Peter

Free Windows Admin Tool Kit Click here and download it now
July 8th, 2015 7:51am

Thanks for the rapid anser ;)

I found the folder, I imagine that the log should be inside the connector's folder. I say I imagine because I don't have any logs for the time being, I'm searching why my methods aren't being called.

Thanks anyway, when I solve that I will probably see some logs

:)

July 8th, 2015 7:58am

No it should not be in a connectors subfolder, instead you should find it directly in the MaData folder
Free Windows Admin Tool Kit Click here and download it now
July 8th, 2015 8:00am

Thanks

Hope I will see it there soon :)

July 8th, 2015 8:01am

Hi Peter,

After a while I finally managed to do some tests and sadly it's not working.

I put the following message in the Initialize section of my extention rule:

Logging.Log("*** LOG TEST ***");

But there is no log file in MaData's folder...

Is there something else that I should do ?

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 7:53am

ok, I found it

In fact I change the XML to

<logging-level>1</logging-level>

now the message

Logging.Log("*** LOG TEST ***");

with is the same as

Logging.Log("*** LOG TEST ***", true, 1);

works well

August 24th, 2015 8:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics