Developer forum

Forum » CMS - Standard features » GlobalSettings for Logs are written wrongly when configuring nested folder

GlobalSettings for Logs are written wrongly when configuring nested folder

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a bit of an annoying bug where the global settings for log retention are written in an invalid format to GlobalSettings.config when you configure nested folders. This is best explained with an example. Let's say I have this configuration:

These settings are stored in global settings as follows:

<FilesRetentionSettings>
  <PurgeEnabled>True</PurgeEnabled>
  <IncludeSubFolders>
    <System>
      <Log>True</Log>
      <Diagnostics>True</Diagnostics>
    </System>
  </IncludeSubFolders>
  <Retention>
    <System>
      <Log>14</Log>
      <Diagnostics>30</Diagnostics>
    </System>
  </Retention>
  <LogLocations>/System/Log|/System/Diagnostics</LogLocations>
</FilesRetentionSettings>

This looks fine to me and registers a 14 and 30 day retention for the System/Log and System/Diagnostics folders respectively.

Now when I add /System/Log/ScheduledTasks as follows:

and save my changes, the file is written as follows:

<FilesRetentionSettings>
  <PurgeEnabled>True</PurgeEnabled>
  <IncludeSubFolders>
    <System>
      <Log>True<ScheduledTasks>False</ScheduledTasks></Log>
      <Diagnostics>True</Diagnostics>
    </System>
  </IncludeSubFolders>
  <Retention>
    <System>
      <Log>30<ScheduledTasks>30</ScheduledTasks></Log>
      <Diagnostics>30</Diagnostics>
    </System>
  </Retention>
  <LogLocations>/System/Log|/System/Diagnostics|/System/Log/ScheduledTasks</LogLocations>
</FilesRetentionSettings>

 

Note how the ScheduledTasks element is now nested inside the Log element.

This is annoying because it'll work OK as long as the site isn't recycled. But when it restarts, the log settings end up broken:

(In other cases, some of the retention settings may contain a number like 3030 (a concatenation of the two values) meaning log files aren't cleared up for a long time which is also bad :-) )

This means no logs are kept so the next time the clean up task runs, all logs are deleted. And that is a big issue for the OData provider using a delta modifier. Tasks that use OData with a delta modifier depend on the last date and time the job ran being written to a log file. It then sends that date as a filter to the ERP (i.e. lastModifiedDateTime=2025-03-01 16:23). When the log file does not exist, no date is added and *all* records are retrieved from the ERP. This has caused multiple cases of importing 200K records in the morning whereas only 2 records had changed :-(

Can this be looked at? I think for the time being I can work around this by not configuring nested folders, but it would be nice to have this work properly.

Imar

 


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

This obviously needs fixing, but have you tried to edit the GlobalSettings to make the XML look exactly as expected?

 

I believe that's how I set some subfolders in the past (were a few that I did them directly there), and I'm not having that problem currently. At least I haven't gone back to the UI and click on "Save".

 

On a separate note, we use a GlobalSettings.Logging.config file to help keep thing separate

 

To add to what you said, we had an awful experience a few weeks ago

  • I did have an issue where in the XML I had a table (i.e. TrackingView), but there was no such table (i.e. Tracking was disabled and I was copying GlobalSettings.Logging.config) and I ended up clicking "Save"
  • Turns out (and I didn't notice that in the UI)
    • if a table doesn't exist, the dropdown renders the first table
      • That was AccessUser
    • The UI is trying to be helpful, so picked up on the DateTime column
      • That was AccessUserValidFrom
  • So, when the scheduled task ran, it wiped out virtually all users and groups
    • That was not fun

 

Thought you (and others) should know :) 

 

BR

Nuno

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> This obviously needs fixing, but have you tried to edit the GlobalSettings to make the XML look exactly as expected?

No,  but I am also not sure what the correct format should be. Somehow it wants ScheduledTasks nested under the logs. I just removed the nested folder for the time being which is fine.

>> So, when the scheduled task ran, it wiped out virtually all users and groups

Ouch, definitely no fun!

Imar
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

I just got the config file from our customer (attached - you happen to know them) but it looks awful as well. Looks like each folder path is an XML node (and I guess you and I were expecting the path to be a value of the node.

 

The attached file has other issues as well, exposed in https://doc.dynamicweb.com/forum/development/development/log-file-setting-repetition-in-globalsettings-aspx so disregard them for now. We're also having to deal with https://doc.dynamicweb.com/forum/cms-standard-features/cms-standard-features/global-settings-writing-to-the-wrong-file so don't try to match exactly with what you see in the screenshot above

 

BR

Nuno

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

That first forum post you linked to is defintely related; similar issue to what I experienced.

 

You must be logged in to post in the forum