-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 support for Socket Logging Handler, enable json format for it #43232
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import java.util.Optional; | ||
import java.util.logging.Formatter; | ||
|
||
import org.wildfly.common.Assert; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
import io.quarkus.runtime.RuntimeValue; | ||
|
||
/** | ||
* The socket format build item. Producing this item will cause the logging subsystem to disregard its | ||
* socket logging formatting configuration and use the formatter provided instead. If multiple formatters | ||
* are enabled at runtime, a warning message is printed and only one is used. | ||
*/ | ||
public final class LogSocketFormatBuildItem extends MultiBuildItem { | ||
private final RuntimeValue<Optional<Formatter>> formatterValue; | ||
|
||
/** | ||
* Construct a new instance. | ||
* | ||
* @param formatterValue the optional formatter runtime value to use (must not be {@code null}) | ||
*/ | ||
public LogSocketFormatBuildItem(final RuntimeValue<Optional<Formatter>> formatterValue) { | ||
this.formatterValue = Assert.checkNotNullParam("formatterValue", formatterValue); | ||
} | ||
|
||
/** | ||
* Get the formatter value. | ||
* | ||
* @return the formatter value | ||
*/ | ||
public RuntimeValue<Optional<Formatter>> getFormatterValue() { | ||
return formatterValue; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.quarkus.runtime.logging; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.Optional; | ||
import java.util.logging.Level; | ||
|
||
import org.jboss.logmanager.handlers.SocketHandler.Protocol; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class SocketConfig { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the late review, but if this is being used specifically to talk to one kind of service, then should we be having a general socket config? I think that users might have a harder time configuring a generic socket handler to talk to some service than if they could have a configuration specific to the kind of service they're talking to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theoretically the socket to which you are writing is independent of the format in which you send the data to it. The Socket handler should allow you to send logs to Splunk too for instance. I've not tried it out though. |
||
|
||
/** | ||
* If socket logging should be enabled | ||
*/ | ||
@ConfigItem | ||
boolean enable; | ||
|
||
/** | ||
* | ||
* The IP address and port of the server receiving the logs | ||
*/ | ||
@ConfigItem(defaultValue = "localhost:4560") | ||
InetSocketAddress endpoint; | ||
|
||
/** | ||
* Sets the protocol used to connect to the syslog server | ||
*/ | ||
@ConfigItem(defaultValue = "tcp") | ||
Protocol protocol; | ||
|
||
/** | ||
* Enables or disables blocking when attempting to reconnect a | ||
* {@link Protocol#TCP | ||
* TCP} or {@link Protocol#SSL_TCP SSL TCP} protocol | ||
*/ | ||
@ConfigItem | ||
boolean blockOnReconnect; | ||
|
||
/** | ||
* The log message format | ||
*/ | ||
@ConfigItem(defaultValue = "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) %s%e%n") | ||
String format; | ||
|
||
/** | ||
* The log level specifying, which message levels will be logged by socket logger | ||
*/ | ||
@ConfigItem(defaultValue = "ALL") | ||
Level level; | ||
|
||
/** | ||
* The name of the filter to link to the file handler. | ||
*/ | ||
@ConfigItem | ||
Optional<String> filter; | ||
|
||
/** | ||
* Socket async logging config | ||
*/ | ||
AsyncConfig async; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this break if we have more than one socket handler configured for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean that we should be able to work with "named" handlers? To allow writing logs to 2 different socket appenders? (Logstash and Splunk for instance)
I must admit I don't know. This is just a copy of
LogFileFormatBuildItem
for instance