I am wanting to enhance a system to execute various background tasks (primarily data importation). In order to provide data for support, analysis and job status generally, I had been thinking of implementing a related table to record task updates e.g.
datetime message
10:00 Job started: status change to EXECUTING
10:01 Job failed because record 101 of file abc.csv is badly formed
10:02 Job status changed to ERROR
...etc.
At some point I thought that this is similar to a regular process log, and so I should customise the SQL sink/appender/provider of a regular log library (e.g. log4net) rather than reinvent the wheel, and then I can also use this for other various logging needs. I had been planning of extending the log model to have a polymorphic relationship with my ImportTask table, and whatever else that might come along after.
e.g.
datetime model model_id message
10:00 Job 22 Job started: status change to EXECUTING
10:01 Job 22 Job failed because record 101 of file abc.csv is badly formed
10:02 Job 22 Job status changed to ERROR
10:03 <null><null> Some other thing happened
...etc.
So then I went looking for examples of this kind of solution and found... nothing. Not even a simple addition of foreign key to a logger. This makes me think I might be on the wrong track.
I did find examples where people are embedding data into the log entry (e.g. as json), however this will not do, as I wish to present the user with the data of the ImportJob, along with related log entries for that item (if the cross reference were encoded json in the log table, then I would have load and decode every log entry to find the related items).
Does adding foreign key attributes to the logging appender make sense, or should I build a custom ImportJobLog type model/table, and leave log4net for general purpose logging?