...

/

Exercise: Logging with Middleware

Exercise: Logging with Middleware

Practice how to create the logging component using the Middleware pattern.

Problem statement

Rewrite the logging component you implemented for “Exercise: Logging with Stretegy” and “Exercise: Logging with Template”, but this time use the Middleware pattern to postprocess each log message allowing different middlewares to customize how to handle the messages and how to output them. We could, for example, add a serialize() middleware to convert the log messages to a string representation ready to be sent over the wire or saved somewhere. Then, we could add a saveToFile() ...