Logging options or best endpoint for health check

Hi Bill. Thanks for your question. Regarding your first question:

  1. Is there a better status endpoint to use for a Health Check that would not be logged? Yes, there’s a better endpoint to use here. You should be able to use the endpoint “…/healthcheck” to determine if the app is alive. If all is well, you should see a response back from the app which returns the word Healthy. This is probably the endpoint you would want to use in your application.

  2. Is there a command line option or environment variable to modify the compute logging level? If you’re specifically targeting the compute.geometry project for logging, then the place to look for how to modify the logging would be in the Startup.cs file. At the bottom of the file, you’ll see a line that looks like Console.WriteLine(msg);. Well, we need to put a check in to only print the message to the console if the request doesn’t include the “…/healthcheck” endpoint. So, the code would now look like this:

if (req.Uri.AbsolutePath != "/healthcheck")
{
    // log request in apache format
    string msg = $"{req.RemoteIpAddress} - [{DateTime.Now:o}] \"{req.Method} {req.Uri.AbsolutePath} {req.Protocol}\" {res.StatusCode} {contentLength}";
    Console.WriteLine(msg);
}

Now, it would only print the console message if it’s anything other than the healthcheck endpoint. We’ve already added this code to the code base, but if you would rather simply replace your existing build of the compute.geometry project, that would work too. You can download the latest build artifact of the compute.geometry project from this link: https://ci.appveyor.com/api/projects/mcneel/compute-rhino3d/artifacts/compute.zip?branch=master

Simply, unzip the contents and replace your existing compute.geometry folder (this should be located at C:\Users\name\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\Hops\0.10.1) with this new one.

We will be working to clean up the console logging so that it is a little cleaner and easier to read. Thanks for your suggestions!

1 Like