romanpierson / vertx-web-accesslog Goto Github PK
View Code? Open in Web Editor NEWAn access log implementation to be used in vert web routes - inspired by apache / tomcat access log configuration
License: Apache License 2.0
An access log implementation to be used in vert web routes - inspired by apache / tomcat access log configuration
License: Apache License 2.0
Hi Roman,
I am interesting in using vertx-web-accesslog but I notice that you have no licensing information.
If you agree would it be possible to get a standard MIT license or failing that an Apace license added to LICENSE.txt in the root folder ?
Many thanks
Hello everyone,
Sometimes when deploying an vertx application (AWS ECS/Fargate) the initialization fails for on obvious reason.
hocon-config is pretty much similar to the one provided in this repos documentation:
configurations = [
{
identifier: accesslog-formatted
logPattern: "%H cs-method \"cs-uri\" HTTP/sc-status took %Dms %Bbytes"
appenders = [
{
appenderClassName: com.romanpierson.vertx.web.accesslogger.appender.logging.impl.LoggingAppender
config {
loggerName: accesslog
}
}
]
}
]
Exception:
com.romanpierson.vertx.web.accesslogger.exception.AccessLoggerException: Unable to register access log configuration [accesslog-formatted]
at com.romanpierson.vertx.web.accesslogger.impl.AccessLoggerHandlerImpl.lambda$new$0(AccessLoggerHandlerImpl.java:131)
at io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153)
at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)
at io.vertx.core.impl.future.FutureImpl.addListener(FutureImpl.java:191)
at io.vertx.core.impl.future.PromiseImpl.addListener(PromiseImpl.java:23)
at io.vertx.core.impl.future.FutureImpl.onComplete(FutureImpl.java:164)
at io.vertx.core.impl.future.PromiseImpl.onComplete(PromiseImpl.java:23)
at io.vertx.core.eventbus.EventBus.request(EventBus.java:107)
at io.vertx.core.eventbus.EventBus.request(EventBus.java:85)
at com.romanpierson.vertx.web.accesslogger.impl.AccessLoggerHandlerImpl.lambda$new$1(AccessLoggerHandlerImpl.java:98)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at com.romanpierson.vertx.web.accesslogger.impl.AccessLoggerHandlerImpl.<init>(AccessLoggerHandlerImpl.java:90)
at com.romanpierson.vertx.web.accesslogger.AccessLoggerHandler.create(AccessLoggerHandler.java:39)
at de.thisismana.VertexWithAccessLogs.lambda$start$2(VertexWithAccessLogs.java:66)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Mapping.onSuccess(Mapping.java:40)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Mapping.onSuccess(Mapping.java:40)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.CompositeFutureImpl.trySucceed(CompositeFutureImpl.java:163)
at io.vertx.core.impl.future.CompositeFutureImpl.lambda$all$0(CompositeFutureImpl.java:38)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.SucceededFuture.addListener(SucceededFuture.java:88)
at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: (NO_HANDLERS,-1) No handlers for address accesslog.event.register
at io.vertx.core.eventbus.impl.EventBusImpl.deliverMessageLocally(EventBusImpl.java:384)
at io.vertx.core.eventbus.impl.EventBusImpl.sendLocally(EventBusImpl.java:341)
at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPub(EventBusImpl.java:329)
at io.vertx.core.eventbus.impl.OutboundDeliveryContext.execute(OutboundDeliveryContext.java:109)
at io.vertx.core.eventbus.impl.DeliveryContextBase.next(DeliveryContextBase.java:72)
at io.vertx.core.eventbus.impl.OutboundDeliveryContext.next(OutboundDeliveryContext.java:28)
at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:422)
at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:428)
at io.vertx.core.eventbus.impl.EventBusImpl.request(EventBusImpl.java:127)
at io.vertx.core.eventbus.EventBus.request(EventBus.java:106)
... 38 more
Usually a restart fixes things. But access logging will permanently fail for affected instances with the following error log:
[AccessLoggerHandlerImpl] Handler not ready to log due to missing registration(s)
The order of initialization is like this. So config
should be ready at this point:
ConfigStoreOptions store = new ConfigStoreOptions()
.setType("file")
.setFormat("hocon")
.setConfig(new JsonObject().put("path", "application.conf"));
ConfigRetriever retriever = ConfigRetriever.create(vertx,
new ConfigRetrieverOptions().addStore(store));
retriever.getConfig()
.onFailure(log::error)
.onComplete(json -> {
var config = json.result();
router.route().handler(AccessLoggerHandler.create(config));
Any idea what might cause this behavior (like a race condition)? Unfortunately, I'm quite new to vertx and cannot reproduce it on my machine nor when starting the very same docker image used on the production system.
Hi, I tried to follow your example to implement access logs on a vertix project and I have this error :
SEVERE: Unhandled exception
java.lang.NoSuchMethodError: io.vertx.core.Vertx.deployVerticle(Ljava/lang/String;Lio/vertx/core/DeploymentOptions;)Lio/vertx/core/Future;
I have added the yaml configuration you had in your readme like this :
public static void main(final String[] args) {
Launcher.executeCommand("run", MainVerticle.class.getName());
}
//@OverRide
public void start(Future startFuture) throws Exception {
JsonObject config= new JsonObject()
.put("path", "src/main/conf/configuration.yaml");
ConfigStoreOptions store = new ConfigStoreOptions()
.setType("file")
.setFormat("yaml")
.setConfig(config);
ConfigRetriever retriever = ConfigRetriever.create(vertx,
new ConfigRetrieverOptions().addStore(store));
retriever.getConfig(json -> {
JsonObject result = json.result();
Router router = Router.router(vertx);
router.route().handler(AccessLoggerHandler.create(result));
HttpServer server = vertx.createHttpServer();
server.requestHandler(request -> {
// This handler gets called for each request that arrives on the server
HttpServerResponse response = request.response();
response.putHeader("content-type", "text/plain");
// Write to the response and end it
response.end("Hello World!");
});
server.listen(8080);
});
Thanks
Hi,
Bintray/JCenter has announced discontinuation of repository according to this announcement.
Is there any plan to change the repository to any other repository?
Think about a way to optionally allow defining physical log destination without depending on a standard log framework
I noticed you made commits for 3.5 vertx, will that new version be published on bintray? Looks like the version on bintray is from before such changes
I looked at the build.gradle but it doesn't show any group:artifact:version info
I found an issue when re-ordering the elements in the log output pattern. If you change the logPattern in the server-config.yaml file to be "%m %D cs-uri" the example application crashes.
The issue appears to be caused by failing to resolve all the pattern elements in com.mdac.vertx.web.accesslogger.configuration.pattern.PatternResolver#resolvePattern. I've raised a pull request that adds a unit test and attempts to fix the issue by moving the offset check to only run if the extracted position is == to the previously found element.
I wasn't certain of the purpose of checking the offset, perhaps it can be ignored completely?
Happy to hear any comments.
Pull request: #10
Hey, thanks for creating the access logger handler.
This is more of an inquiry than an issue, but I've been using 1.0.0 for a long while now and I have seen no need to upgrade to the latest version yet. However, I've been looking to upgrade to Vertx 3.8.4 and in that version, they got rid of the io.vertx.ext.web.impl.Utils.createRFC1123DateTimeFormatter()
method which is still used in a few places in the 1.0.0 version of this package. So I was thinking of upgrading to the latest version, but it seems to me that there are some pretty major changes that I am unsure if I want to take on i.e use of a worker verticle and event bus to facilitate logging.
Since I'm perfectly content with 1.0.0 except for the no longer valid method from Vertx Utils, I am tempted to fork the old version and replace the invalid method usage. But before I do that, I want to inquire if there are any stronger reasons why it would be good to use the latest version instead?
Thanks a lot!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.