I have already looked at this question enter link description here
however i cant seem to find the answer to WHY there is a composition between the two objects
The link to the uml is here:
Can anyone explain to me why there is a composition? or why there should be anything other than the generalization?
Because the point of the decorator pattern is to decorate a contained component:
Using the above, the decorator can be used anywhere you would use any other logger, and the decorator can decorate any kind of logger (console, file, email, socket, whatever). It doesn’t care what the concrete logger does (print to the console or print to a file). All it does is decorate the concrete logger, by adding the current date to the message before letting the delegate logger print it.
If you had to do this without composition (or rather delegation), you would have to create a
WithCurrentDateFileLoggerand aWithCurrentDateConsoleLogger(add one subclass for each concrete logger). And every other decoration or concrete logger type would make the number of classes to create explode, due to the high number of combinations.