Hi
is it possible to write to the output log in my custom provider ? be it source or destination provider ?
Hi
is it possible to write to the output log in my custom provider ? be it source or destination provider ?
Hi Casper,
Yes it is possible. You can try to use the standard logging.
The logger is located in the namespace: Dynamicweb.Data.Providers.Logger.
Usually the logger is used in the destination provider, but if needed you can try to use it in the source provider.
In order to use the logging, you have to inherit your provider from the Dynamicweb.Data.Providers.BaseProvider
and initialize the logger as the first thing in destination provider RunJob - simply add this line:
SetupLogging(logFile);
and then you can use it like: Logger.Log("message");
For the source provider use you need to add this line in the LoadSettings(Job job, string logFile) method:
SetupLogging(logFile);
and then use the logger.
If you don't want to inherit your provider from the BaseProvider you can define your own Logger property in source/destination provider and use the following code to initialize it:
void SetupLogging(string logFile)
{
Logger = new Logger(logFile);
}
Regards, Dmitrij
In order to use the logging, you have to initialize it as the first thing in runJob - simply add this line:
SetupLogging(logFile);
- See more at: http://developer.dynamicweb.com/forum.aspx?PID=48&ThreadID=37013#sthash.QBj16D8L.dpufIn order to use the logging, you have to initialize it as the first thing in runJob - simply add this line:
SetupLogging(logFile);
- See more at: http://developer.dynamicweb.com/forum.aspx?PID=48&ThreadID=37013#sthash.QBj16D8L.dpufOk great thanks! just last question, where do i fingd Dynamicweb.Data.Providers.Logger since i cant find that dll anywhere
In the Dynamicweb.Data.Providers.dll
Ahh sorry i misunderstood you.
So now i have created
public void SetupLogging(string logFile)
{
Logger Logger = new Logger(logFile);
}
and used SetupLogging(logFile) as the first thing in my RunJob method, this is for my destination provider, but when i try and do Logger.Log i dont see Log i only see Logger.readlog
Am i missing something ?
Hi Casper,
this is becasue the readLog is a static method and you can all it directly from the type name without making a class instance. And you have made a wrong syntax in your SetupLogging mthod, see:
Logger Logger = new Logger(logFile); - here you have made just a local variable which is not a class member.
You need to define a class property like:
protected Dynamicweb.Data.Providers.Logger Logger { get; set; }
and inside SetupLogging initialize it:
Logger = new Logger(logFile);
after that you should be able to use it.
Ahh that made much more sense and it is working now! Thanks a lot
You must be logged in to post in the forum