Logging to Datasource

Hello,
I'm trying TMS Logging and it works well.
I would like to save the logs in a database table.
I read in the documentation to use
TMSLogger.RegisterOutputHandlerClass(TTMSLoggerDataSourceOutputHandler, [DataSource1]);

Ok, but the table must already be present? a TTable or TQuery?

I connected a datasource and TFDMemtable with 2 fields: Name, ProcessID. But the Logger add only blank records

I don't understand where I wrong

If many concurrent calls arrive, is it necessary to manage multithreading or is the database a bottleneck?

If you have an example it would be useful to me. I will use Devart components instead of Firedac, but I think it doesn't change anything.

thanks
regards
Antonello

Hello @Carlomagno_Antonello,

Yes, you must associate a dataset to the datasource component.

The dataset fields must be all of string type, and you must provide the field names in the Handler.Fields property, for example:

  var Handler := TTMSLoggerDataSourceOutputHandler.Create(DataSource1);
  Handler.Fields.Name := 'LOG_NAME';
  Handler.Fields.Value := 'LOG_VALUE';
  Handler.Fields.Timestamp := 'LOG_TIMESTAMP';
  TMSLogger.RegisterOutputHandlerClass(Handler);

Multithread is managed by TMS Logging by serializing the message logging mechanism.

Hello @wlandgraf
thanks for answer.

I tried but I have a error in this line:
TMSLogger.RegisterOutputHandlerClass(Handler);

the error:

[dcc32 Error] Unit1.pas(47): E2250 There is no overloaded version of 'RegisterOutputHandlerClass' that can be called with these arguments

I tried with this
TMSlogger.RegisterOutputHandler(Handler);

Compile the sample, but the records is always blank

regards
Antonello

Hello @wlandgraf

sorry, works, I accidentally commented out a line.

It works with this call
TMSlogger.RegisterOutputHandler(Handler);

but the LOG_NAME is always empty... do I have to log the name in a particular way?

Antonello

That was just an example, just set the field names you want to output to the database. Name is indeed a specific field used only when logging objects.

ah ok, I thought it was the name of the log you wanted to log

thanks for support!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.