-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a syslog encoder and sink #96
Comments
Eventually, yes - supporting syslog will require both a syslog encoder (similar to zap's current JSON encoder) and a We're definitely not going to get to this until after a 1.0 release, though. |
Hi @akshayjshah |
@skypacer210 This issue is not related to writing to a file, but specifically to the syslog interface. You can write to a file using zap, take a look at I've filed #100 so we have an example to point to for file logging. |
@akshayjshah Thanks a lot! |
@akshayjshah Do zap support logging with rotation? |
@skypacer210 Please look at existing documentation and issues, there is a separate issue about this: #98. As I mentioned earlier, this issue is not related to writing to a file, but about the syslog interface, so let's move the discussion of logging to file away from this issue. |
@prashantv Got it, thanks. |
I actually implemented a nearly completed Syslog friendly encoder (mostly just a slightly modified JSON encoder) and a syslog writer. But I can't finish it because The problem is: syslog writer need to know the To achieve this I suggest create the new following interface:
and use it instead of For writers that don't need the level such to use
If this change to zap internal API is approved, I can finish implement syslog support. |
Adding This struct is almost the same as
|
@bclermont Thanks for putting in the time to prototype this! I'd also like to make an interface changes generic enough that we have a fighting chance of supporting other encodings and sinks down the road. Modifying However, I would like to preserve the separation of encoders and outputs. While the syslog format and syslog outputs are pretty tightly coupled, this sort of thing is broadly useful - for example, it's reasonable to support different files per log level (or per name, if we implement #130). To support those use cases cleanly, I do think we'll need to rethink the interface that outputs provide; @bclermont This discussion might be a bit easier if you open a PR with your code, even if it's incomplete - at least then we'll have a concrete implementation to look at. |
In case anybody is interested in syslog, you might want to check https://github.com/tchap/zapext/blob/master/zapsyslog/core.go ;-) Exemplar usage can be found here: https://github.com/tchap/zapext/blob/master/zapsyslog/example/main.go |
I implemented syslog writer in my own application so I made pull request if you are interested in using it in your library |
As part of the discussion on #96, it's clear that we need to make it easier for third-party packages to extend zap's functionality. Some of that requires new APIs, but we'll also need a way to refer people from the core zap package to the various extensions. This PR adds an FAQ entry that lists the extensions we're aware of. It's currently a little hard to find (the GoDoc includes a link to the FAQ, but it's not very prominent). We'll address that as part of a documentation revamp later on.
Awesome - thanks, @avidak. Clearly, we've been thinking about this a lot internally without posting updates on this issue - sorry, everyone! I don't think that it's a good idea to include this functionality inside zap itself. I do agree that it's important, and clearly many of you need it. However, we don't use syslog internally, and none of the zap maintainers have any experience with it. We're committed to supporting this project, including fixing bugs...which will be very difficult for anything syslog-related. As a small example, none of us are certain whether it's okay to send msgpack-encoded (or other binary) logs to syslog. To make sure that the syslog integration is well-supported and works correctly, it should be maintained by someone who actually uses it and understands syslog. @tchap has already written such an extension, which I'm happy to send users to. I've added a table of extensions to zap's FAQ in #576; as we revamp the zap docs, that table will become more prominent. Again, sorry for the long silence on this issue. I hope that this approach ends up being good for everyone: users get a supported, battle-tested syslog integration, and zap itself remains understandable to the core maintainers. I'll leave this issue open for a bit, in case we need a bit more discussion. |
As part of the discussion on #96, it's clear that we need to make it easier for third-party packages to extend zap's functionality. Some of that requires new APIs, but we'll also need a way to refer people from the core zap package to the various extensions. This PR adds an FAQ entry that lists the extensions we're aware of. It's currently a little hard to find (the GoDoc includes a link to the FAQ, but it's not very prominent). We'll address that as part of a documentation revamp later on.
As part of the discussion on uber-go#96, it's clear that we need to make it easier for third-party packages to extend zap's functionality. Some of that requires new APIs, but we'll also need a way to refer people from the core zap package to the various extensions. This PR adds an FAQ entry that lists the extensions we're aware of. It's currently a little hard to find (the GoDoc includes a link to the FAQ, but it's not very prominent). We'll address that as part of a documentation revamp later on.
now zap can write to stderr and stdout...
Is any plan to support syslog?
The text was updated successfully, but these errors were encountered: