Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Logging in DLL and main application


#1

I am using RAD XE2 (Delphi) under W7/64 and would like to add logging to my dlls as I have it already in my main application.

My main application uses a set of dynamically loaded dlls that I load on demand and I would like to add logging there as well. How can I accomplish this? Can I use the same instance of SiMain in the main application and the dlls? Is there any topic here dealing with this kind of problem?

Many thanks in advance for your prompt answer.

John


#2

Hello John,

Thanks for your posting. Yes, this is supported:

http://www.gurock.com/smartinspect/using-smartinspect-logging-in-delphi-dlls.a.html

You would basically need to use the SmartInspect BPL in order to reference the same Si/SiMain objects in your application and the DLLs.

I hope this helps,
Tobias


#3

Hi Tobias,

Thanks for pointing me to the right direction.

I think I did exactely what the example shows but I do not get any log entries altogether.

The difference between my app and the example though is that my dll is loaded dynamically at run time of the main app and is not statically bound to it. Can this cause this behaviour?

Any hint would be appreciated!

John


#4

Hi Tobias,

I found out what was wrong - it works now!

Is there a way to use different logging files and objects for the main app and dlls without having to use runtime dll?

John


#5

Hello John,

If you don’t want to use the runtime packages (and thus compile the .dcus directly into your application/dlls), you would automatically get different SmartInspect objects for your application and dlls. You would then need to configure the Si objects separately and can also use different log files. This would be the standard approach actually and the runtime packages are only needed if you want to use the same Si objects in your application and the dlls.

I hope this helps,
Tobias