How to override path or disable SpeckleLog

Hey guys,

I am running on an issue where Speckle.Core.Logging.SpeckleLog is trying to create a directory and I am running my application on an environment without permissions to do so. I am looking for a way to disable the log or override the path for the logs where I have permissions.

Do you have any ideas?

Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\Users\acesuser\AppData\Roaming\Speckle' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at Speckle.Core.Helpers.SpecklePathProvider.LogFolderPath(String hostApplicationName, String hostApplicationVersion)
   at Speckle.Core.Logging.SpeckleLog.CreateConfiguredLogger(String hostApplicationName, String hostApplicationVersion, SpeckleLogConfiguration logConfiguration)
   at Speckle.Core.Logging.SpeckleLog.Initialize(String hostApplicationName, String hostApplicationVersion, SpeckleLogConfiguration logConfiguration)
   at Ark.Revit.Core.<SendToSpeckle>d__1.MoveNext()

Hi @vwb

You can make a call to this Setup.Init function in the entry point of your application (call before using any Speckle types)

You can pass a SpeckleLogConfig where you can customise where we’ll log to.

e.g. to just log to console you can do this:

Setup.Init("v1", "myApp", new SpeckleLogConfiguration(LogEventLevel.Debug, true, false, false, false, false));
1 Like

Thanks Jedd,

Unfortunately I tried that without success. It seems like Setup.Init → SpeckleLog.Initialize → CreateConfiguredLogger is where things go south for me. The call in line 180 is the one trying to ensure that the directory exists, no matter what config I pass down to it. There’s even a TODO note that would be amazing if it was solved for me :smiley:

Or… Do you have any other ideas?

1 Like

Oh damn, ok.

Are you running in an environment that has zero disk access, or is it specifically the default path provided by the SpecklePathProvider that’s the problem.
Because, with SpecklePathProvider.OverrideApplicationDataPath you may beable to specificy a different directory.

I’ll look into this function some more, seems like we should probably fix the CreateConfiguredLogger

It worked!!!



I have an idea for how we could avoid checking paths if file logging is disabled (in the CreateConfiguredLogger )

Please let me know if you’d want this change in for the hackathon.
But If its not blocking you right now, I’m going to consider this a low priority and will park my PR. It will need some more testing before I’m happy with it.

I’ll keep the PR there lined up in case its needed during the hackathon, otherwise we’ll try and get sorted for a future release.

Please let us know if you have any other problems r.e. file system access.