EventLog link to file

James Mosquito asked on February 3, 2021 14:35

Hi, I am creating a ScheduledTask and would like to include a link to a file when it completes. Is there a way to do this using the EventLogProvider or can you suggest an alternative approach?

Thanks, James

Correct Answer

Brenden Kehren answered on February 3, 2021 15:57

Ok I see the issue now. The all the field values are output into asp:label controls don't support HTML that well. Secondly, in code, they StripTags() and HTMLEncode() the output. This is most likely the culprit.

Check out the EventLog_Details.aspx.cs file in the /CMSModules/EventLog/ directory, at line 189. While I don't recommend changing the base Xperience files, this would be a pretty harmless change and in the event it was overwritten during an upgrade, it would be a simple fix to re-implment.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on February 3, 2021 15:12

The EventLogProvider itself won't store your file, but your scheduled task could store the file in the file system then before your schedule task completes you can take and create a link to that file and put that in the description of the event log as HTML and make that a link.

I'd suggest storing the file in some place that would be accessible by the system for example in your site file where the media library would be stored.

0 votesVote for this answer Mark as a Correct answer

James Mosquito answered on February 3, 2021 15:44

Thanks Brenden,

I tried including some html in the eventDescription but it seems to get stripped out when viewing the log entry e.g.

This:

EventLogProvider.LogInformation("MyTask", "TaskComplete", "Download link: <a href='linktofile'>Click to download</a>");

Becomes the following in plain text:

Download Link Click to download

Did I miss something, or does eventDescription markup need to be rendered another way?

P.S. I am using Kentico 12 SP.

Thanks, James

0 votesVote for this answer Mark as a Correct answer

James Mosquito answered on February 4, 2021 10:50

Great, thanks Brenden

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.