In the latest release of scriptcs.rebus, it is possible to receive the log entries from a remote script execution process. On the client side you can define a number of log entry handlers, and specify at which log level they should receive the log entries.

Out of the box there is a console log handler, the ToConsole(), which you can add like this:

Copy to Clipboard

You can specify the at which log level you would like to receive logs entries in the console like this:

Copy to Clipboard

Now this would make all log entries with log level Debug send to the console of the client. This is great, but what if I’d like to get all log entries of LogLevel.Error put into a rolling file? Well, easy, you just implement the IReceiveLogEntries interface, and then add it.

This is an example of a simple, and yet naive, rolling file implementation:

Copy to Clipboard

Now we can add this rolling file logger to our list of log entry handlers like this:

Copy to Clipboard

This sends the all LogLevel.Debug, and below, entries to the console, while all LogLevel.Error, and below, are sent to a rolling file.

Other examples of log entry handlers could be SQL Server, MongoDB, RavenDB, Azure Blob Storage, etc. I might post examples of these in futures posts.

Throw me a comment below or ping me on Twitter, to let hear what you think of this feature.

Recent Posts

Tags