Closed JakobChristensen closed 8 years ago
Make sure all calls to Console is though the ConsoleService.
All calls to Console now uses the IConsoleService. Some calls cannot use IConsoleService, since the CompositionService is not yet loaded. Todo: On the server, write diagnostics to the log files.
I did some investigation on this issue.
All appropriate Console.Write are routed through the IConsoleService. If the IConsoleService is not available, Console is used.
I have added a try...catch to all controllers for exceptions that are no caught - these will be logged to the Sitecore.Log.
Every controller captures the Console output and writes any output back to the Http response - as far as I can see, everything is sent back to the client.
I do not think every bit of Console output should be logged to the Sitecore log - but if that is what we want, we can reopen this issue.
I consider the issue closed for now.
This is related to the above issue. Inside the StartupExtensions class where we load the configuration, there is a try/catch and in the catch we write to the console. This class also runs on the server (as it does in the above case) in which case we never see the error messages. Instead, we should have a logging service which all components use and this service directs the output to an appropriate location based on how the app is running. If the Sitecore log file is available, log to that. If not, log to the console. There is a lot of usage of Console throughout the code. We should encapsulate that into a service and use the service instead. Classes should never have to worry about changing the colour before writing to the console, that should be abstracted behind a method call on the trace service: trace.warning(“warning title”, “warning description”)