Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Abdul Majid 10 posts 80 karma points
    Feb 08, 2021 @ 19:08
    Abdul Majid
    0

    Move Umbraco log to Azure storage account

    Hi, I am trying to move the Umbraco log files to Azure storage account. I have install package Serilog.Sinks.AzureBlobStorage and updated the serilog.user.config with the following appSettings:

    <!-- Azure blog storage -->
        <add key="serilog:using:AzureBlobStorage" value="Serilog.Sinks.AzureBlobStorage" />
        <add key="serilog:write-to:AzureBlobStorage.connectionString" value="DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[KEY];EndpointSuffix=core.windows.net" />
        <add key="serilog:write-to:AzureBlobStorage.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
        <add key="serilog:write-to:AzureBlobStorage.storageContainerName" value="[ContainerName]"/>
        <add key="serilog:write-to:AzureBlobStorage.storageFileName" value="[FileName.txt]"/>
    

    I can see the logs being generated in the correct storage account and container, but the site does not load... the page is waiting for loading.

    I've tried, moving the appSetting to serilog.config commenting out the default Json log file and still getting the same issue. Has anyone else experience the same issue? BTW I am running the site locally on my machine with IIS. Also run the site in debug mode IIS Express, able to replicate the same issue.

    If I remove the above appSettings, the site loads without any issue. So not sure what I am missing that might cause this issue. Any help would be much apricated.

  • Andy Boot 50 posts 192 karma points MVP
    Aug 04, 2021 @ 11:09
    Andy Boot
    1

    Hi,

    Did you ever find out what the issue was?

    I'm attempting to get this set up in the exact same way you have and getting the same timeout issues. I can see the log file on the blob container, but errors.

    Thanks,

    Andy

  • Abdul Majid 10 posts 80 karma points
    Aug 11, 2021 @ 14:19
    Abdul Majid
    0

    Hi Andy,

    Apologies for the delay in responding. Unfortunately I was not able to resolve the issue.

  • Andy Boot 50 posts 192 karma points MVP
    Aug 11, 2021 @ 15:32
    Andy Boot
    0

    Hey Abdul,

    You must be a mind reader as I was actually in the middle of sorting it as I received your reply.

    I'm happy to say that within the past few minutes that I've got this sorted. Instead of using Azure Blob Storage, use Azure Table Storage instead, it's far easier to work with and I guess there might be some performance gains via this method.

    Here's a forum post which helped me: https://our.umbraco.com/forum/umbraco-8/97245-umbraco-8-serilog-and-serilog-sinks#comment-321674 I think the author followed Umbraco's own documentation and slightly adapted it: https://our.umbraco.com/documentation/Fundamentals/Backoffice/LogViewer/

    I made another small alteration of my own by moving the configuration out of the serilog.config/serilog.user.config and just having them in the appSettings of the web.config and doing the following to avoid having the connection string hard coded:

    var appSetting = ConfigurationManager.AppSettings["serilog:write-to:AzureTableStorage.connectionString"];
    var cloudStorage = CloudStorageAccount.Parse(appSetting);
    

    And here's what it'll look like within Azure Storage Explorer: Azure Table

    All the best,

    Andy

  • Abdul Majid 10 posts 80 karma points
    Sep 01, 2021 @ 00:04
    Abdul Majid
    0

    Thanks for all thr reply, I finally got it working with Azure log analytics workspace.

  • Andy Finn 51 posts 183 karma points
    Dec 08, 2021 @ 15:47
    Andy Finn
    0

    @andy how did u move the serialog.user.config setting to webconfig ? I made another small alteration of my own by moving the configuration out of the serilog.config/serilog.user.config and just having them in the appSettings of the web.config and doing the following to avoid having the connection string hard coded:

    You can in the class , for the log viewer , but the settings in the seriallog.config , will still have the connection string ?

    Andy

  • Andy Boot 50 posts 192 karma points MVP
    Dec 08, 2021 @ 15:56
    Andy Boot
    2

    Sorry I thought I had posted an update to this thread with an update following an observation I made following a deployment to a live server.

    When I say I moved the configuration out of the serilog.config/serilog.user.config to the web.config, I mean I literally copied & pasted the settings.

    HOWEVER, by doing that it will not create the Azure Table upon needing to set up logging in another environment / new Azure account.

    It would still be worth keeping the connection string app setting in the web.config rather than having to hard code it into your compiled code. Yeah it's duplication of settings, but I haven't yet found a method of consolidating the setting into one place where Serilog can find the right config, and the LogViewer code can also find the same setting.

    Interested to know if anybody knows how!

  • Andy Finn 51 posts 183 karma points
    Dec 15, 2021 @ 22:39
    Andy Finn
    0

    @andy , finally figure out how to get this to work in multi env . We have a prod / test / dev , in azure so using the azure server variables works well . when moving from env to env .

Please Sign in or register to post replies

Write your reply to:

Draft