Open lxl-renren opened 8 months ago
it's unclear why this needs to be in the standard library when it can accomplished as a handler. as the first example I found: https://github.com/samber/slog-multi
I agree other third-party library like "slog-multi" accomplished this functionality. Although third-party solutions exist, standardizing this functionality offers several benefits:
Using third-party library like "slog-multi" may not be maintained consistently, potentially leading to compatibility issues in the future.
CC @jba
@lxl-renren While I agree with you about the values of standardization, I don't think this particular feature warrants it. It is easy enough to write and not needed often enough to justify the added maintenance burden to the Go team.
However, that is just my opinion, and we can and should let the proposal process take its course.
I want this feature too. As I know, lots of project will save logs to multi target , example:
current slog can not support such case.
If we need to log in two different outputs, we can use io.Multiwriter logger = slog.New( slog.NewJSONHandler(io.MultiWriter(fileWriter, os.Stdout), &slog.HandlerOptions{}), ) If we need to log in two different output with different values, example:
we can warp slog in a custom Logger and handling this sutiations.
Proposal Details
Currently slog package a logger only support one handler. For most language like python, A log module should be sent to multiple targets for output simultaneously for a logger. This feature is necessary, I propose adding multiple handlers support for logger. cc @golang/proposal-review